Submission #215663


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);
void swap(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;
  }
}
*/

void D1solve(int n, int m, int d, vector<int>& a, vector<int>& b){
  vector<int> tmp(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;
}


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

Submission Info

Submission Time
Task D - 阿弥陀
User solanumaple
Language C++ (G++ 4.6.4)
Score 30
Code Size 2019 Byte
Status TLE
Exec Time 4066 ms
Memory 3088 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 × 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 AC 594 ms 3088 KB
01_random01.txt AC 23 ms 884 KB
01_random02.txt AC 23 ms 924 KB
01_random03.txt AC 23 ms 916 KB
01_random04.txt AC 45 ms 880 KB
01_random05.txt AC 411 ms 2276 KB
01_random06.txt AC 435 ms 2724 KB
01_random07.txt AC 462 ms 2912 KB
02_i.txt AC 31 ms 812 KB
02_p.txt AC 29 ms 896 KB
02_random01.txt AC 52 ms 804 KB
02_random02.txt AC 24 ms 808 KB
02_random03.txt AC 26 ms 928 KB
02_random04.txt AC 29 ms 816 KB
02_random05.txt AC 89 ms 936 KB
02_random06.txt AC 39 ms 1308 KB
02_random07.txt AC 61 ms 1636 KB
02_random08.txt AC 72 ms 1660 KB
02_rp01.txt AC 29 ms 876 KB
02_rp02.txt AC 29 ms 868 KB
02_rp03.txt AC 28 ms 928 KB
02_rp04.txt AC 28 ms 924 KB
02_rp05.txt AC 57 ms 804 KB
03_i.txt TLE 4031 ms 932 KB
03_random01.txt AC 365 ms 920 KB
03_random02.txt AC 748 ms 1580 KB
03_random03.txt AC 1565 ms 1452 KB
03_random04.txt AC 960 ms 1556 KB
03_random05.txt TLE 4044 ms 1128 KB
03_random06.txt TLE 4033 ms 1116 KB
03_random07.txt TLE 4032 ms 1132 KB
03_random08.txt AC 591 ms 884 KB
03_random09.txt AC 1668 ms 1060 KB
03_random10.txt TLE 4037 ms 1384 KB
03_random11.txt TLE 4032 ms 1652 KB
03_random12.txt TLE 4032 ms 1644 KB
03_random13.txt AC 2831 ms 1384 KB
03_random14.txt AC 367 ms 1304 KB
03_random15.txt TLE 4031 ms 1192 KB
04_i.txt TLE 4036 ms 2852 KB
04_p1.txt TLE 4044 ms 2504 KB
04_p2.txt TLE 4032 ms 2184 KB
04_random01.txt TLE 4033 ms 2064 KB
04_random02.txt TLE 4032 ms 1716 KB
04_random03.txt TLE 4033 ms 1432 KB
04_random04.txt TLE 4031 ms 1832 KB
04_random05.txt TLE 4033 ms 1752 KB
04_random06.txt TLE 4031 ms 2048 KB
04_random07.txt TLE 4066 ms 2212 KB
04_random08.txt TLE 4036 ms 1948 KB
04_random09.txt TLE 4032 ms 1896 KB
04_random10.txt TLE 4035 ms 1916 KB
04_random11.txt TLE 4031 ms 2908 KB
04_random12.txt TLE 4047 ms 2980 KB
04_random13.txt TLE 4034 ms 2920 KB
04_rp01.txt TLE 4053 ms 2464 KB
04_rp02.txt TLE 4032 ms 2536 KB
04_rp03.txt TLE 4035 ms 2484 KB
04_rp04.txt TLE 4032 ms 2528 KB
04_rp05.txt TLE 4033 ms 2532 KB
04_rp06.txt TLE 4034 ms 2532 KB
04_rp07.txt TLE 4039 ms 2472 KB
04_rp08.txt TLE 4032 ms 2468 KB
04_rp09.txt TLE 4034 ms 2460 KB
04_rp10.txt TLE 4033 ms 2464 KB
sample_1.txt AC 24 ms 924 KB
sample_2.txt AC 36 ms 808 KB
sample_3.txt AC 24 ms 924 KB