Submission #655596


Source Code Expand

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<climits>
#include<ctime>
#include<cstring>
#include<sstream>
#define REP(i,p,n) for(int i=p;i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep_split(tok,a_str,re) for(char *tok = strtok((char *)a_str.c_str(),re); tok != NULL; tok = strtok(NULL,re))
#define ALL(c) (c).begin(), (c).end()
#define dump(a) cerr << #a << "=" << (a) << endl
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> void chmin(T &t, T f) { if (t > f) t = f; } //t=min
template<class T> void chmax(T &t, T f) { if (t < f) t = f; } //t=max
using namespace std;
 
int main()
{
	int N,M,D;
	int index;
	vector<int> A;
	vector<int> to;
 
	cin >> N >> M >> D;
	int doubling[N+1][31];
 
	rep(i,M) {
		cin >> index;
		A.push_back(index);
	}
	reverse(ALL(A)); // Why?
 
	rep(i,N+1) { //0 ~ N
		to.push_back(i);
	}

    for(int i = 1; i <= N; ++i)
        doubling[ i ][ 0 ] = i;
	
	//阿弥陀のシュミレーション
	rep(i,M) {
		swap(doubling[A[i]][0],doubling[A[i]+1][0]);
	}
 
	REP(k,1,30) { //2^1 ~ 2^30
		REP(i,1,N+1) {
            int f = doubling[ i ][ k - 1 ];
			doubling[i][k] = doubling[f][k-1];
		}
	}
 
	//ダブリング:工程2
	REP(i,1,N+1) {
		int next = i;
		int DD = D;
 
		rep(k,30+1)
		{
			if (DD & 1) {
				next = doubling[next][k];
			}
			DD = DD >> 1;
		}
		cout << next << endl;
	}
 
	return 0;
}

Submission Info

Submission Time
Task D - 阿弥陀
User Ow1
Language C++11 (GCC 4.8.1)
Score 100
Code Size 1565 Byte
Status AC
Exec Time 501 ms
Memory 14564 KB

Judge Result

Set Name Subtask1 Subtask2 Subtask3 Subtask4
Score / Max Score 10 / 10 20 / 20 20 / 20 50 / 50
Status
AC × 9
AC × 18
AC × 18
AC × 29
Set Name Test Cases
Subtask1 sample_1.txt, 01_i.txt, 01_random01.txt, 01_random02.txt, 01_random03.txt, 01_random04.txt, 01_random05.txt, 01_random06.txt, 01_random07.txt
Subtask2 sample_1.txt, sample_2.txt, sample_3.txt, 02_i.txt, 02_p.txt, 02_random01.txt, 02_random02.txt, 02_random03.txt, 02_random04.txt, 02_random05.txt, 02_random06.txt, 02_random07.txt, 02_random08.txt, 02_rp01.txt, 02_rp02.txt, 02_rp03.txt, 02_rp04.txt, 02_rp05.txt
Subtask3 sample_1.txt, sample_2.txt, 03_i.txt, 03_random01.txt, 03_random02.txt, 03_random03.txt, 03_random04.txt, 03_random05.txt, 03_random06.txt, 03_random07.txt, 03_random08.txt, 03_random09.txt, 03_random10.txt, 03_random11.txt, 03_random12.txt, 03_random13.txt, 03_random14.txt, 03_random15.txt
Subtask4 sample_1.txt, sample_2.txt, sample_3.txt, 04_i.txt, 04_p1.txt, 04_p2.txt, 04_random01.txt, 04_random02.txt, 04_random03.txt, 04_random04.txt, 04_random05.txt, 04_random06.txt, 04_random07.txt, 04_random08.txt, 04_random09.txt, 04_random10.txt, 04_random11.txt, 04_random12.txt, 04_random13.txt, 04_rp01.txt, 04_rp02.txt, 04_rp03.txt, 04_rp04.txt, 04_rp05.txt, 04_rp06.txt, 04_rp07.txt, 04_rp08.txt, 04_rp09.txt, 04_rp10.txt
Case Name Status Exec Time Memory
01_i.txt AC 445 ms 14560 KB
01_random01.txt AC 27 ms 876 KB
01_random02.txt AC 27 ms 796 KB
01_random03.txt AC 26 ms 796 KB
01_random04.txt AC 40 ms 1260 KB
01_random05.txt AC 402 ms 13540 KB
01_random06.txt AC 459 ms 14436 KB
01_random07.txt AC 498 ms 14564 KB
02_i.txt AC 31 ms 1000 KB
02_p.txt AC 31 ms 880 KB
02_random01.txt AC 25 ms 916 KB
02_random02.txt AC 26 ms 924 KB
02_random03.txt AC 31 ms 876 KB
02_random04.txt AC 31 ms 1004 KB
02_random05.txt AC 38 ms 1124 KB
02_random06.txt AC 72 ms 1516 KB
02_random07.txt AC 115 ms 2020 KB
02_random08.txt AC 115 ms 2016 KB
02_rp01.txt AC 31 ms 1012 KB
02_rp02.txt AC 33 ms 1048 KB
02_rp03.txt AC 31 ms 1000 KB
02_rp04.txt AC 31 ms 924 KB
02_rp05.txt AC 29 ms 928 KB
03_i.txt AC 26 ms 884 KB
03_random01.txt AC 30 ms 1012 KB
03_random02.txt AC 86 ms 2000 KB
03_random03.txt AC 78 ms 2016 KB
03_random04.txt AC 76 ms 2016 KB
03_random05.txt AC 36 ms 1004 KB
03_random06.txt AC 36 ms 1008 KB
03_random07.txt AC 40 ms 1140 KB
03_random08.txt AC 26 ms 872 KB
03_random09.txt AC 44 ms 1260 KB
03_random10.txt AC 58 ms 1508 KB
03_random11.txt AC 85 ms 1956 KB
03_random12.txt AC 88 ms 2020 KB
03_random13.txt AC 74 ms 2016 KB
03_random14.txt AC 65 ms 1516 KB
03_random15.txt AC 40 ms 1264 KB
04_i.txt AC 501 ms 14560 KB
04_p1.txt AC 437 ms 13804 KB
04_p2.txt AC 353 ms 11108 KB
04_random01.txt AC 264 ms 8360 KB
04_random02.txt AC 197 ms 6564 KB
04_random03.txt AC 112 ms 2620 KB
04_random04.txt AC 148 ms 2648 KB
04_random05.txt AC 148 ms 3132 KB
04_random06.txt AC 236 ms 8896 KB
04_random07.txt AC 229 ms 6236 KB
04_random08.txt AC 199 ms 5336 KB
04_random09.txt AC 180 ms 3796 KB
04_random10.txt AC 257 ms 8800 KB
04_random11.txt AC 464 ms 14556 KB
04_random12.txt AC 430 ms 14560 KB
04_random13.txt AC 501 ms 14552 KB
04_rp01.txt AC 373 ms 13800 KB
04_rp02.txt AC 371 ms 13764 KB
04_rp03.txt AC 410 ms 13792 KB
04_rp04.txt AC 416 ms 13888 KB
04_rp05.txt AC 418 ms 13780 KB
04_rp06.txt AC 427 ms 13788 KB
04_rp07.txt AC 421 ms 13792 KB
04_rp08.txt AC 426 ms 13792 KB
04_rp09.txt AC 421 ms 13788 KB
04_rp10.txt AC 440 ms 13792 KB
sample_1.txt AC 26 ms 800 KB
sample_2.txt AC 26 ms 796 KB
sample_3.txt AC 26 ms 868 KB