Submission #215666


Source Code Expand

Copy
#include<iostream>

#define MAX_N 100000
#define MAX_M 200000

using namespace std;
void D1solve(int, int, int, int[], int[]);
void Dnsolve(int[], int[], int, int);
void swap(int*, int*);


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

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

  //solve
  int b[MAX_N+1];
  int c[MAX_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(int b[], int c[], int d, int n){
  int tmp[MAX_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, int a[], int b[]){
  int tmp[MAX_N+1];
  for(int i = 1; i <= n; i++){
    tmp[i] = i; //indexを現在の場所,tmp[index]の値を元の場所とする
  }
  for(int j = 1; j <= m; j++){
    swap(&tmp[a[j]], &tmp[a[j]+1]);
  }

  for(int k = 1; k <= n; k++)
    b[tmp[k]]  = k; //indexを元の場所, b[index]をたどり着いた場所として返す

}

void swap(int* l, int* r){
  int tmp;
  tmp = *l;
  *l = *r;
  *r = tmp;
}

Submission Info

Submission Time
Task D - 阿弥陀
User solanumaple
Language C++ (G++ 4.6.4)
Score 30
Code Size 1427 Byte
Status TLE
Exec Time 4033 ms
Memory 3048 KB

Judge Result

Set Name Subtask1 Subtask2 Subtask3 Subtask4
Score / Max Score 10 / 10 20 / 20 0 / 20 0 / 50
Status
AC × 9
AC × 18
AC × 12
TLE × 6
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 AC 436 ms 3000 KB
01_random01.txt AC 24 ms 996 KB
01_random02.txt AC 25 ms 1004 KB
01_random03.txt AC 24 ms 872 KB
01_random04.txt AC 37 ms 1000 KB
01_random05.txt AC 401 ms 2368 KB
01_random06.txt AC 424 ms 2932 KB
01_random07.txt AC 428 ms 3048 KB
02_i.txt AC 29 ms 1052 KB
02_p.txt AC 29 ms 924 KB
02_random01.txt AC 25 ms 920 KB
02_random02.txt AC 25 ms 1000 KB
02_random03.txt AC 26 ms 1008 KB
02_random04.txt AC 29 ms 880 KB
02_random05.txt AC 31 ms 980 KB
02_random06.txt AC 41 ms 1384 KB
02_random07.txt AC 55 ms 1780 KB
02_random08.txt AC 54 ms 1772 KB
02_rp01.txt AC 28 ms 880 KB
02_rp02.txt AC 29 ms 1012 KB
02_rp03.txt AC 29 ms 884 KB
02_rp04.txt AC 28 ms 984 KB
02_rp05.txt AC 29 ms 928 KB
03_i.txt TLE 4031 ms 1008 KB
03_random01.txt AC 715 ms 1004 KB
03_random02.txt AC 1479 ms 1644 KB
03_random03.txt AC 2995 ms 1520 KB
03_random04.txt AC 905 ms 1704 KB
03_random05.txt TLE 4030 ms 1132 KB
03_random06.txt TLE 4031 ms 1132 KB
03_random07.txt TLE 4031 ms 1196 KB
03_random08.txt AC 525 ms 928 KB
03_random09.txt AC 1379 ms 1196 KB
03_random10.txt AC 3515 ms 1384 KB
03_random11.txt TLE 4031 ms 1712 KB
03_random12.txt AC 3477 ms 1836 KB
03_random13.txt AC 2358 ms 1580 KB
03_random14.txt AC 308 ms 1384 KB
03_random15.txt TLE 4032 ms 1132 KB
04_i.txt TLE 4031 ms 2664 KB
04_p1.txt TLE 4031 ms 2156 KB
04_p2.txt TLE 4032 ms 1964 KB
04_random01.txt TLE 4031 ms 1764 KB
04_random02.txt TLE 4033 ms 1496 KB
04_random03.txt TLE 4031 ms 1520 KB
04_random04.txt TLE 4031 ms 1860 KB
04_random05.txt TLE 4031 ms 1696 KB
04_random06.txt TLE 4031 ms 1780 KB
04_random07.txt TLE 4030 ms 2152 KB
04_random08.txt TLE 4031 ms 1984 KB
04_random09.txt TLE 4031 ms 1964 KB
04_random10.txt TLE 4031 ms 1776 KB
04_random11.txt TLE 4031 ms 2668 KB
04_random12.txt TLE 4031 ms 2528 KB
04_random13.txt TLE 4032 ms 2544 KB
04_rp01.txt TLE 4032 ms 2156 KB
04_rp02.txt TLE 4032 ms 2152 KB
04_rp03.txt TLE 4032 ms 2156 KB
04_rp04.txt TLE 4031 ms 2160 KB
04_rp05.txt TLE 4030 ms 2160 KB
04_rp06.txt TLE 4032 ms 2228 KB
04_rp07.txt TLE 4030 ms 2220 KB
04_rp08.txt TLE 4032 ms 2224 KB
04_rp09.txt TLE 4031 ms 2152 KB
04_rp10.txt TLE 4032 ms 2156 KB
sample_1.txt AC 24 ms 860 KB
sample_2.txt AC 25 ms 1000 KB
sample_3.txt AC 25 ms 1064 KB