結果

問題 No.101 ぐるぐる!あみだくじ!
ユーザー koyoprokoyopro
提出日時 2015-10-01 23:50:29
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 711 bytes
コンパイル時間 1,461 ms
コンパイル使用メモリ 147,752 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-27 01:22:03
合計ジャッジ時間 25,867 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 188 ms
4,376 KB
testcase_12 AC 184 ms
4,380 KB
testcase_13 AC 192 ms
4,376 KB
testcase_14 AC 261 ms
4,380 KB
testcase_15 AC 20 ms
4,376 KB
testcase_16 AC 23 ms
4,380 KB
testcase_17 AC 27 ms
4,380 KB
testcase_18 AC 33 ms
4,380 KB
testcase_19 AC 38 ms
4,380 KB
testcase_20 AC 3 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 60 ms
4,376 KB
testcase_23 AC 31 ms
4,380 KB
testcase_24 AC 521 ms
4,380 KB
testcase_25 AC 355 ms
4,380 KB
testcase_26 AC 259 ms
4,380 KB
testcase_27 AC 4,030 ms
4,380 KB
testcase_28 AC 2,429 ms
4,376 KB
testcase_29 AC 2,275 ms
4,380 KB
testcase_30 AC 1,857 ms
4,380 KB
testcase_31 AC 1,812 ms
4,380 KB
testcase_32 AC 1,787 ms
4,376 KB
testcase_33 TLE -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;

#define REP(i, n) for(int i=0; i<(n); i++)

int N,K;
bool isok(vector<int> a) {
    REP(i,a.size()) {
        if (a[i] != i) return false;
    }
    return true;
}
signed main()
{
    cin >> N>>K;
    vector<int> amida(N);
    REP(i,N) amida[i] = i;
    vector<int> x(K);
    int y;
    REP(i,K) {
        cin >> x[i] >> y;
        swap(amida[x[i]-1], amida[x[i]]);
    }
    int cnt = 0;
    vector<int> tmp(N);
    REP(i,N) tmp[i] = i;
    while(true) {
        cnt++;
        vector<int> tmp2(N);
        REP(i,N) {
            tmp2[i] = tmp[amida[i]];
        }
        if (isok(tmp2)) break;
        tmp = tmp2;
    }
    cout << cnt << endl;
    return 0;
}
0