AtCoder Grand Contest 007

Submission #1355522

Source codeソースコード

#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N;
	cin >> N;
	vector<int> P(N);
	vector<int> A(N),B(N);
	for(int i=0;i<N;++i){
		cin >> P[i];
		--P[i];
	}
	const int vMAX = 20001;
	for(int i=0;i<N;++i){
		B[i] = vMAX*vMAX+vMAX*(N-i);
	}
	for(int i=0;i<N;++i){
		A[i] = vMAX*(i+1);
	}

	int pos,prev;
	pos = 0;
	prev = -1;
	LL prevVal;
	for(int i=0;i<N;++i){
		int index = P[i];
		if( i ){
			A[ index ] = prevVal - B[index] + 1;
			prevVal = A[index] + B[index];
		}else{//i==0
			prev =  P[i];
			prevVal = A[index] + B[index];
		}
	}
	for(int i=0;i<N;++i){
		if( i ) cout << ' ';
		cout << A[i];
	}cout << endl;
	for(int i=0;i<N;++i){
		if( i ) cout << ' ';
		cout << B[i];
	}cout << endl;
	/*for(int i=0;i<N;++i){
		if( i ) cerr << ' ';
		int pos = P[i];
		cerr << A[pos] + B[pos];
	}*/
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	
	
	solve();
}
#pragma endregion //main()

Submission

Task問題 B - Construct Sequences
User nameユーザ名 akarin55
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 AC
Score得点 400
Source lengthソースコード長 1988 Byte
File nameファイル名
Exec time実行時間 6 ms
Memory usageメモリ使用量 896 KB

Test case

Set

Set name Score得点 / Max score Cases
Sample - example0.txt,example1.txt,example2.txt
All 400 / 400 000.txt,001.txt,002.txt,003.txt,004.txt,005.txt,006.txt,007.txt,008.txt,009.txt,010.txt,011.txt,012.txt,013.txt,014.txt,015.txt,016.txt,017.txt,018.txt,example0.txt,example1.txt,example2.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
000.txt AC 2 ms 384 KB
001.txt AC 2 ms 256 KB
002.txt AC 2 ms 256 KB
003.txt AC 1 ms 256 KB
004.txt AC 2 ms 256 KB
005.txt AC 6 ms 896 KB
006.txt AC 2 ms 384 KB
007.txt AC 6 ms 768 KB
008.txt AC 4 ms 640 KB
009.txt AC 6 ms 896 KB
010.txt AC 6 ms 896 KB
011.txt AC 6 ms 896 KB
012.txt AC 6 ms 896 KB
013.txt AC 6 ms 896 KB
014.txt AC 6 ms 896 KB
015.txt AC 6 ms 896 KB
016.txt AC 6 ms 896 KB
017.txt AC 6 ms 896 KB
018.txt AC 6 ms 896 KB
example0.txt AC 1 ms 256 KB
example1.txt AC 1 ms 256 KB
example2.txt AC 1 ms 256 KB