Contest Duration: - (local time) (120 minutes) Back to Home

Submission #215660

Source Code Expand

Copy
#include<iostream>
#include<vector>
/*
#include<iomanip>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<string>
#include<sstream>
#include<ncurses.h>
*/

using namespace std;
void D1solve(int, int, int, vector<int>&, vector<int>&);
void Dnsolve(vector<int>&, vector<int>&, int, int);

int main(){
ios::sync_with_stdio(false);

//入力
int n, m, d;
vector<int> a;
cin >> n >> m >> d;
a.assign(m+1, 0);
a[0] = 0;
for(int i = 1; i <= m; i++) cin >> a[i];
//入力

//solve
vector<int> b(n+1);
vector<int> c(n+1);
//solve

D1solve(n, m, d, a, b);

if( d == 1 ){
for(int i = 1; i < n+1; i++)
cout << b[i] << endl;
}else{
Dnsolve(b, c, d, n);
for(int i = 1; i < n+1; i++)
cout << c[i] << endl;
}

return 0;
}

void Dnsolve(vector<int>& b, vector<int>& c, int d, int n){
vector<int> tmp(n+1);
for(int i = 1; i <= n; i++) tmp[i] = i;
for(int dd = 0; dd < d; dd++){
for(int j = 1; j <= n; j++){
tmp[j] = b[tmp[j]];
}
}
for(int k = 1; k <= n; k++) c[k] = tmp[k];

}

void D1solve(int n, int m, int d, vector<int>& a, vector<int>& b){
/* */
for(int i = 1; i <= n; i++){
int current = i;
for(int j = 1; j <= m; j++){
if( current == a[j] ) current++;
else if( current-1 == a[j] ) current--;
}
b[i] = current;
}
/*/
for(int i = 1; i <= m; i++) cout << a[i] << endl;
int current = 2;
for(int j = 1; j <= m; j++){
if( current = a[j] ){
current++;
cout << current << endl;
}else if( current - 1 == a[j] ){
current--;
cout << current << endl;
}
}
b[2] = current;
/* */
}

//index番目がb[index]に移動する

#### Submission Info

Submission Time 2014-08-18 10:46:59+0900 D - 阿弥陀 solanumaple C++ (G++ 4.6.4) 20 1806 Byte TLE 4039 ms 2476 KB

#### Judge Result

Set Name Subtask1 Subtask2 Subtask3 Subtask4
Score / Max Score 0 / 10 20 / 20 0 / 20 0 / 50
Status
 AC × 5 TLE × 4
 AC × 18
 AC × 10 TLE × 8
 AC × 3 TLE × 26
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 TLE 4030 ms 2468 KB
01_random01.txt AC 21 ms 928 KB
01_random02.txt AC 21 ms 808 KB
01_random03.txt AC 22 ms 804 KB
01_random04.txt AC 90 ms 928 KB
01_random05.txt TLE 4029 ms 1780 KB
01_random06.txt TLE 4029 ms 2196 KB
01_random07.txt TLE 4030 ms 2464 KB
02_i.txt AC 30 ms 812 KB
02_p.txt AC 28 ms 804 KB
02_random01.txt AC 22 ms 800 KB
02_random02.txt AC 21 ms 928 KB
02_random03.txt AC 31 ms 924 KB
02_random04.txt AC 27 ms 924 KB
02_random05.txt AC 65 ms 808 KB
02_random06.txt AC 228 ms 1316 KB
02_random07.txt AC 432 ms 1580 KB
02_random08.txt AC 433 ms 1580 KB
02_rp01.txt AC 30 ms 732 KB
02_rp02.txt AC 29 ms 928 KB
02_rp03.txt AC 27 ms 796 KB
02_rp04.txt AC 32 ms 932 KB
02_rp05.txt AC 29 ms 928 KB
03_i.txt TLE 4029 ms 932 KB
03_random01.txt AC 362 ms 928 KB
03_random02.txt AC 738 ms 1568 KB
03_random03.txt AC 1524 ms 1452 KB
03_random04.txt AC 947 ms 1312 KB
03_random05.txt TLE 4030 ms 1064 KB
03_random06.txt TLE 4029 ms 932 KB
03_random07.txt TLE 4033 ms 1004 KB
03_random08.txt AC 584 ms 924 KB
03_random09.txt AC 1599 ms 1052 KB
03_random10.txt TLE 4029 ms 1312 KB
03_random11.txt TLE 4032 ms 1632 KB
03_random12.txt TLE 4029 ms 1572 KB
03_random13.txt AC 2807 ms 1312 KB
03_random14.txt AC 363 ms 1308 KB
03_random15.txt TLE 4028 ms 1056 KB
04_i.txt TLE 4030 ms 2420 KB
04_p1.txt TLE 4030 ms 2092 KB
04_p2.txt TLE 4030 ms 1760 KB
04_random01.txt TLE 4029 ms 1692 KB
04_random02.txt TLE 4029 ms 1572 KB
04_random03.txt TLE 4030 ms 1440 KB
04_random04.txt TLE 4030 ms 1704 KB
04_random05.txt TLE 4028 ms 1688 KB
04_random06.txt TLE 4030 ms 1636 KB
04_random07.txt TLE 4030 ms 1956 KB
04_random08.txt TLE 4029 ms 1832 KB
04_random09.txt TLE 4030 ms 1776 KB
04_random10.txt TLE 4029 ms 1568 KB
04_random11.txt TLE 4029 ms 2396 KB
04_random12.txt TLE 4030 ms 2476 KB
04_random13.txt TLE 4030 ms 2476 KB
04_rp01.txt TLE 4039 ms 2080 KB
04_rp02.txt TLE 4030 ms 2084 KB
04_rp03.txt TLE 4030 ms 2088 KB
04_rp04.txt TLE 4030 ms 2084 KB
04_rp05.txt TLE 4029 ms 2084 KB
04_rp06.txt TLE 4029 ms 2008 KB
04_rp07.txt TLE 4029 ms 2064 KB
04_rp08.txt TLE 4030 ms 2076 KB
04_rp09.txt TLE 4032 ms 2088 KB
04_rp10.txt TLE 4029 ms 2088 KB
sample_1.txt AC 21 ms 920 KB
sample_2.txt AC 21 ms 736 KB
sample_3.txt AC 21 ms 728 KB