Submission #1714042


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define FORR(x, arr) for(auto& x:arr)
#define ITR(x, c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;
typedef pair<int, int> P;

int n, m, d, to[100005], ans[100005];
bool used[100005];
P p[100005];

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n >> m >> d;
	FOR(i, n) to[i] = i;
	FOR(i, m) {
		int a;
		cin >> a;
		swap(to[a-1], to[a]);
	}
	vector<vector<int> > v;
	FOR(i, n) {
		if (used[i]) continue;
		v.push_back(vector<int>(1, i));
		used[i] = true;
		p[i] = {v.size()-1, v.back().size()-1};
		for (int j = to[i]; j != i; j = to[j]) {
			v.back().push_back(j);
			used[j] = true;
			p[j] = {v.size()-1, v.back().size()-1};
		}
	}
	FORR(e, v) {
		int sz = e.size(), mod = d%sz;
		FOR(i, e.size()) {
			ans[e[i]] = e[(i+mod)%sz];
		}
	}
	vector<int> ret(n);
	FOR(i, n) ret[ans[i]] = i+1;
	FOR(i, n) cout << ret[i] << endl;
	return 0;
}

Submission Info

Submission Time
Task D - 阿弥陀
User moguta
Language C++14 (GCC 5.4.1)
Score 100
Code Size 1172 Byte
Status AC
Exec Time 190 ms
Memory 8624 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 186 ms 8624 KB
01_random01.txt AC 1 ms 256 KB
01_random02.txt AC 2 ms 256 KB
01_random03.txt AC 1 ms 256 KB
01_random04.txt AC 7 ms 384 KB
01_random05.txt AC 170 ms 7088 KB
01_random06.txt AC 181 ms 5556 KB
01_random07.txt AC 183 ms 5300 KB
02_i.txt AC 3 ms 384 KB
02_p.txt AC 3 ms 256 KB
02_random01.txt AC 2 ms 256 KB
02_random02.txt AC 1 ms 256 KB
02_random03.txt AC 3 ms 256 KB
02_random04.txt AC 3 ms 384 KB
02_random05.txt AC 5 ms 256 KB
02_random06.txt AC 10 ms 256 KB
02_random07.txt AC 17 ms 256 KB
02_random08.txt AC 17 ms 256 KB
02_rp01.txt AC 3 ms 256 KB
02_rp02.txt AC 3 ms 256 KB
02_rp03.txt AC 3 ms 256 KB
02_rp04.txt AC 3 ms 256 KB
02_rp05.txt AC 3 ms 256 KB
03_i.txt AC 1 ms 256 KB
03_random01.txt AC 3 ms 256 KB
03_random02.txt AC 13 ms 256 KB
03_random03.txt AC 11 ms 256 KB
03_random04.txt AC 11 ms 256 KB
03_random05.txt AC 3 ms 256 KB
03_random06.txt AC 3 ms 256 KB
03_random07.txt AC 4 ms 256 KB
03_random08.txt AC 2 ms 256 KB
03_random09.txt AC 5 ms 256 KB
03_random10.txt AC 8 ms 256 KB
03_random11.txt AC 13 ms 256 KB
03_random12.txt AC 13 ms 256 KB
03_random13.txt AC 10 ms 256 KB
03_random14.txt AC 8 ms 256 KB
03_random15.txt AC 4 ms 256 KB
04_i.txt AC 188 ms 8496 KB
04_p1.txt AC 171 ms 3456 KB
04_p2.txt AC 134 ms 2816 KB
04_random01.txt AC 102 ms 3128 KB
04_random02.txt AC 77 ms 2872 KB
04_random03.txt AC 26 ms 768 KB
04_random04.txt AC 30 ms 640 KB
04_random05.txt AC 37 ms 896 KB
04_random06.txt AC 109 ms 3512 KB
04_random07.txt AC 75 ms 1852 KB
04_random08.txt AC 65 ms 1596 KB
04_random09.txt AC 45 ms 1024 KB
04_random10.txt AC 109 ms 3764 KB
04_random11.txt AC 190 ms 5300 KB
04_random12.txt AC 186 ms 5300 KB
04_random13.txt AC 186 ms 5300 KB
04_rp01.txt AC 172 ms 3320 KB
04_rp02.txt AC 176 ms 3320 KB
04_rp03.txt AC 174 ms 3452 KB
04_rp04.txt AC 174 ms 3324 KB
04_rp05.txt AC 173 ms 3324 KB
04_rp06.txt AC 173 ms 3452 KB
04_rp07.txt AC 168 ms 3324 KB
04_rp08.txt AC 169 ms 3324 KB
04_rp09.txt AC 167 ms 3320 KB
04_rp10.txt AC 170 ms 3324 KB
sample_1.txt AC 1 ms 256 KB
sample_2.txt AC 2 ms 256 KB
sample_3.txt AC 2 ms 256 KB