Submission #1192059


Source Code Expand

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

int main() {
  int n, m, d;
  scanf("%d%d%d", &n, &m, &d);
  vi amida(n);
  rep (i, n) amida[i] = i;

  rep (i, m) {
    int index;
    scanf("%d", &index);
    swap(amida[index-1], amida[index]);
  }
  vi move(n);
  rep (i, n) move[amida[i]] = i;

  unordered_map<int, vi> umv;
  vi group(n, -1);
  vi ans(n);
  rep (i, n) {
    if (group[i] >= 0) continue;
    umv[i] = {i};
    for (int j = move[i]; j != i; j = move[j]) {
      umv[i].push_back(j);
      group[j] = i;
    }
    int sz = umv[i].size();
    int ans_index = d % sz;
    rep (j, sz) {
      ans[umv[i][j]] = umv[i][(ans_index + j) % sz];
    }
  }

  rep (i, n) {
    printf("%d\n", ans[i] + 1);
  }

  return 0;
}

Submission Info

Submission Time
Task D - 阿弥陀
User tspcx
Language C++14 (Clang 3.8.0)
Score 100
Code Size 1581 Byte
Status AC
Exec Time 54 ms
Memory 12576 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 54 ms 12576 KB
01_random01.txt AC 1 ms 256 KB
01_random02.txt AC 1 ms 256 KB
01_random03.txt AC 1 ms 256 KB
01_random04.txt AC 3 ms 384 KB
01_random05.txt AC 36 ms 10400 KB
01_random06.txt AC 44 ms 7220 KB
01_random07.txt AC 49 ms 6836 KB
02_i.txt AC 2 ms 384 KB
02_p.txt AC 1 ms 256 KB
02_random01.txt AC 1 ms 256 KB
02_random02.txt AC 1 ms 256 KB
02_random03.txt AC 2 ms 256 KB
02_random04.txt AC 1 ms 384 KB
02_random05.txt AC 3 ms 256 KB
02_random06.txt AC 10 ms 256 KB
02_random07.txt AC 19 ms 256 KB
02_random08.txt AC 19 ms 256 KB
02_rp01.txt AC 1 ms 256 KB
02_rp02.txt AC 1 ms 256 KB
02_rp03.txt AC 1 ms 256 KB
02_rp04.txt AC 1 ms 256 KB
02_rp05.txt AC 1 ms 256 KB
03_i.txt AC 1 ms 256 KB
03_random01.txt AC 2 ms 256 KB
03_random02.txt AC 16 ms 256 KB
03_random03.txt AC 16 ms 256 KB
03_random04.txt AC 13 ms 256 KB
03_random05.txt AC 4 ms 256 KB
03_random06.txt AC 3 ms 256 KB
03_random07.txt AC 5 ms 256 KB
03_random08.txt AC 1 ms 256 KB
03_random09.txt AC 6 ms 256 KB
03_random10.txt AC 9 ms 256 KB
03_random11.txt AC 15 ms 256 KB
03_random12.txt AC 16 ms 256 KB
03_random13.txt AC 13 ms 256 KB
03_random14.txt AC 10 ms 256 KB
03_random15.txt AC 5 ms 256 KB
04_i.txt AC 54 ms 12576 KB
04_p1.txt AC 27 ms 2944 KB
04_p2.txt AC 22 ms 2432 KB
04_random01.txt AC 27 ms 3968 KB
04_random02.txt AC 19 ms 3584 KB
04_random03.txt AC 13 ms 768 KB
04_random04.txt AC 20 ms 640 KB
04_random05.txt AC 19 ms 896 KB
04_random06.txt AC 27 ms 4660 KB
04_random07.txt AC 29 ms 2048 KB
04_random08.txt AC 25 ms 1792 KB
04_random09.txt AC 25 ms 1024 KB
04_random10.txt AC 25 ms 5172 KB
04_random11.txt AC 49 ms 6836 KB
04_random12.txt AC 48 ms 6836 KB
04_random13.txt AC 49 ms 6836 KB
04_rp01.txt AC 23 ms 2936 KB
04_rp02.txt AC 24 ms 2808 KB
04_rp03.txt AC 25 ms 2844 KB
04_rp04.txt AC 24 ms 2812 KB
04_rp05.txt AC 26 ms 2944 KB
04_rp06.txt AC 24 ms 2940 KB
04_rp07.txt AC 24 ms 2812 KB
04_rp08.txt AC 25 ms 2940 KB
04_rp09.txt AC 24 ms 2808 KB
04_rp10.txt AC 24 ms 2940 KB
sample_1.txt AC 1 ms 256 KB
sample_2.txt AC 1 ms 256 KB
sample_3.txt AC 1 ms 256 KB