結果
| 問題 |
No.101 ぐるぐる!あみだくじ!
|
| コンテスト | |
| ユーザー |
h_noson
|
| 提出日時 | 2016-03-31 23:46:27 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 759 bytes |
| コンパイル時間 | 605 ms |
| コンパイル使用メモリ | 59,640 KB |
| 実行使用メモリ | 8,320 KB |
| 最終ジャッジ日時 | 2024-10-02 08:41:32 |
| 合計ジャッジ時間 | 21,900 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | AC * 33 TLE * 1 -- * 3 |
ソースコード
#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;
}
h_noson