結果

問題 No.101 ぐるぐる!あみだくじ!
ユーザー h_nosonh_noson
提出日時 2016-03-31 23:46:27
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 759 bytes
コンパイル時間 495 ms
コンパイル使用メモリ 59,996 KB
実行使用メモリ 8,576 KB
最終ジャッジ日時 2024-04-10 06:59:02
合計ジャッジ時間 22,271 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 159 ms
5,376 KB
testcase_12 AC 165 ms
5,376 KB
testcase_13 AC 169 ms
5,376 KB
testcase_14 AC 231 ms
5,376 KB
testcase_15 AC 18 ms
5,376 KB
testcase_16 AC 21 ms
5,376 KB
testcase_17 AC 23 ms
5,376 KB
testcase_18 AC 30 ms
5,376 KB
testcase_19 AC 33 ms
5,376 KB
testcase_20 AC 3 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 51 ms
5,376 KB
testcase_23 AC 28 ms
5,376 KB
testcase_24 AC 461 ms
5,376 KB
testcase_25 AC 316 ms
5,376 KB
testcase_26 AC 234 ms
5,376 KB
testcase_27 AC 3,625 ms
5,376 KB
testcase_28 AC 2,174 ms
5,376 KB
testcase_29 AC 2,016 ms
5,376 KB
testcase_30 AC 1,660 ms
5,376 KB
testcase_31 AC 1,614 ms
5,376 KB
testcase_32 AC 1,616 ms
5,376 KB
testcase_33 TLE -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

#define RREP(i,s,e) for (i = s; i >= e; i--)
#define rrep(i,n) RREP(i,n,0)
#define REP(i,s,e) for (i = s; i < e; i++)
#define rep(i,n) REP(i,0,n)
#define INF 100000000

typedef long long ll;

int main() {
    int i, n, k;
    int move[101], now[2][101];
    cin >> n >> k;
    REP (i,1,n+1) move[i] = i;
    rep (i,k) {
        int x, y;
        cin >> x >> y;
        swap(move[x],move[y]);
    }
    REP (i,1,n+1) now[0][i] = i;
    bool ok;
    int ans = 0;
    do {
        ok = true;
        REP (i,1,n+1) now[(ans+1)%2][i] = now[ans%2][move[i]];
        REP (i,1,n+1) ok &= now[(ans+1)%2][i] == i;
        ans++;
    } while (!ok);
    cout << ans << endl;
    return 0;
}
0