Submission #214020


Source Code Expand

Copy
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <fstream>
#include <bitset>

using namespace std;

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
template <typename T> void print_container(ostream& os, const T& c) { const char* _s = " "; if (!c.empty()) { __typeof__(c.begin()) last = --c.end(); foreach (it, c) { os << *it; if (it != last) os << _s; } } }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& c) { print_container(os, c); return os; }
template <typename T> ostream& operator<<(ostream& os, const set<T>& c) { print_container(os, c); return os; }
template <typename T> ostream& operator<<(ostream& os, const multiset<T>& c) { print_container(os, c); return os; }
template <typename T> ostream& operator<<(ostream& os, const deque<T>& c) { print_container(os, c); return os; }
template <typename T, typename U> ostream& operator<<(ostream& os, const map<T, U>& c) { print_container(os, c); return os; }
template <typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) { os << "(" << p.first << ", " << p.second << ")"; return os; }

template <typename T> void print(T a, int n, const string& split = " ") { for (int i = 0; i < n; i++) { cout << a[i]; if (i + 1 != n) cout << split; } cout << endl; }
template <typename T> void print2d(T a, int w, int h, int width = -1, int br = 0) { for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) { if (width != -1) cout.width(width); cout << a[i][j] << ' '; } cout << endl; } while (br--) cout << endl; }
template <typename T> void input(T& a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
#define dump(v) (cerr << #v << ": " << v << endl)

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define erep(i, n) for (int i = 0; i <= (int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define clr(a, x) memset(a, x, sizeof(a))
#define sz(a) ((int)(a).size())
#define mp(a, b) make_pair(a, b)
#define ten(n) ((long long)(1e##n))

template <typename T, typename U> void upmin(T& a, const U& b) { a = min<T>(a, b); }
template <typename T, typename U> void upmax(T& a, const U& b) { a = max<T>(a, b); }
template <typename T> void uniq(T& a) { sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); }
template <class T> string to_s(const T& a) { ostringstream os; os << a; return os.str(); }
template <class T> T to_T(const string& s) { istringstream is(s); T res; is >> res; return res; }
void fast_io() { cin.tie(0); ios::sync_with_stdio(false); }
bool in_rect(int x, int y, int w, int h) { return 0 <= x && x < w && 0 <= y && y < h; }

typedef long long ll;
typedef pair<int, int> pint;

const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };



int main()
{
    fast_io();

    int n, m, d;
    cin >> n >> m >> d;
    vector<int> from(n);
    rep(i, n)
        from[i] = i;
    rep(i, m)
    {
        int a;
        cin >> a;
        --a;
        swap(from[a], from[a + 1]);
    }
    vector<int> to(n);
    rep(i, n)
        to[from[i]] = i;

    vector<vector<int>> group;
    vector<pint> id(n, pint(-1, -1));
    rep(i, n)
    {
        if (id[i].first == -1)
        {
            int g_id = group.size();
            group.push_back(vector<int>());
            for (int p = i; id[p].first == -1; p = to[p])
            {
                id[p] = pint(g_id, group.back().size());
                group.back().push_back(p);
            }
        }
    }

    rep(i, n)
    {
        int g_id = id[i].first;
        int pos = id[i].second;
        cout << group[g_id][(pos + d) % group[g_id].size()] + 1 << endl;
    }
}

Submission Info

Submission Time
Task D - 阿弥陀
User takapt
Language C++11 (GCC 4.8.1)
Score 100
Code Size 4160 Byte
Status AC
Exec Time 456 ms
Memory 8404 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 456 ms 8404 KB
01_random01.txt AC 23 ms 772 KB
01_random02.txt AC 21 ms 800 KB
01_random03.txt AC 20 ms 928 KB
01_random04.txt AC 33 ms 928 KB
01_random05.txt AC 429 ms 7512 KB
01_random06.txt AC 434 ms 5544 KB
01_random07.txt AC 442 ms 5340 KB
02_i.txt AC 25 ms 800 KB
02_p.txt AC 25 ms 804 KB
02_random01.txt AC 21 ms 924 KB
02_random02.txt AC 22 ms 924 KB
02_random03.txt AC 24 ms 924 KB
02_random04.txt AC 25 ms 928 KB
02_random05.txt AC 29 ms 764 KB
02_random06.txt AC 35 ms 932 KB
02_random07.txt AC 47 ms 732 KB
02_random08.txt AC 47 ms 924 KB
02_rp01.txt AC 25 ms 804 KB
02_rp02.txt AC 25 ms 928 KB
02_rp03.txt AC 27 ms 764 KB
02_rp04.txt AC 27 ms 796 KB
02_rp05.txt AC 26 ms 928 KB
03_i.txt AC 21 ms 796 KB
03_random01.txt AC 22 ms 792 KB
03_random02.txt AC 38 ms 804 KB
03_random03.txt AC 35 ms 928 KB
03_random04.txt AC 36 ms 924 KB
03_random05.txt AC 24 ms 804 KB
03_random06.txt AC 24 ms 928 KB
03_random07.txt AC 25 ms 924 KB
03_random08.txt AC 22 ms 808 KB
03_random09.txt AC 26 ms 804 KB
03_random10.txt AC 31 ms 924 KB
03_random11.txt AC 36 ms 924 KB
03_random12.txt AC 37 ms 916 KB
03_random13.txt AC 33 ms 924 KB
03_random14.txt AC 32 ms 924 KB
03_random15.txt AC 24 ms 928 KB
04_i.txt AC 452 ms 8404 KB
04_p1.txt AC 409 ms 3492 KB
04_p2.txt AC 332 ms 2980 KB
04_random01.txt AC 253 ms 3280 KB
04_random02.txt AC 199 ms 3036 KB
04_random03.txt AC 74 ms 1136 KB
04_random04.txt AC 77 ms 1048 KB
04_random05.txt AC 94 ms 1316 KB
04_random06.txt AC 269 ms 3668 KB
04_random07.txt AC 184 ms 2140 KB
04_random08.txt AC 159 ms 1948 KB
04_random09.txt AC 113 ms 1312 KB
04_random10.txt AC 266 ms 4320 KB
04_random11.txt AC 449 ms 5460 KB
04_random12.txt AC 443 ms 5328 KB
04_random13.txt AC 448 ms 5268 KB
04_rp01.txt AC 418 ms 3348 KB
04_rp02.txt AC 415 ms 3368 KB
04_rp03.txt AC 419 ms 3400 KB
04_rp04.txt AC 409 ms 3360 KB
04_rp05.txt AC 411 ms 3364 KB
04_rp06.txt AC 416 ms 3352 KB
04_rp07.txt AC 423 ms 3356 KB
04_rp08.txt AC 410 ms 3360 KB
04_rp09.txt AC 409 ms 3356 KB
04_rp10.txt AC 425 ms 3420 KB
sample_1.txt AC 21 ms 928 KB
sample_2.txt AC 21 ms 928 KB
sample_3.txt AC 21 ms 928 KB