結果

問題 No.101 ぐるぐる!あみだくじ!
ユーザー imgry22imgry22
提出日時 2014-12-12 12:43:49
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,223 bytes
コンパイル時間 1,749 ms
コンパイル使用メモリ 144,300 KB
実行使用メモリ 7,588 KB
最終ジャッジ日時 2023-09-02 14:20:37
合計ジャッジ時間 23,300 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 780 ms
4,376 KB
testcase_12 AC 1,361 ms
4,384 KB
testcase_13 AC 1,715 ms
4,380 KB
testcase_14 AC 1,251 ms
4,380 KB
testcase_15 AC 118 ms
4,380 KB
testcase_16 AC 169 ms
4,376 KB
testcase_17 AC 170 ms
4,376 KB
testcase_18 AC 150 ms
4,376 KB
testcase_19 AC 223 ms
4,376 KB
testcase_20 AC 9 ms
4,376 KB
testcase_21 AC 9 ms
4,376 KB
testcase_22 AC 284 ms
4,376 KB
testcase_23 AC 259 ms
4,380 KB
testcase_24 AC 2,285 ms
4,376 KB
testcase_25 AC 2,971 ms
4,380 KB
testcase_26 AC 2,339 ms
4,380 KB
testcase_27 TLE -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

typedef long long int ll;
typedef unsigned long long int llu;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;

#define rrep(i, m, n) for(int i=m; i<n;  i++)
#define erep(i, n)    for(int i=1; i<=n; i++)
#define  rep(i, n)    for(int i=0; i<n;  i++)
#define rrev(i, m, n) for(int i=n-1; i>=m; i--)
#define erev(i, n)    for(int i=n; i>=1; i--)
#define  rev(i, n)    for(int i=n-1; i>=0; i--)
#define EACH(v)       (v).begin(), (v).end()
#define CNT(a, n, x)  (upper_bound(a, a+n, x)-lower_bound(a, a+n, x))
#define minup(m, x)   (m=min(m, x))
#define maxup(m, x)   (m=max(m, x))
#define mp            make_pair

#define INF 1000000000
#define MOD 1000000009
#define EPS 1E-9

#define MAX_N 100
#define MAX_K 1000

int n, k;
int x[MAX_K], y[MAX_K];
int res;
int num[MAX_N];
bool flag;

int main()
{
  cin >> n >> k;
  rep(i, k) cin >> x[i] >> y[i];
  rep(i, k) x[i] -= 1;
  rep(i, k) y[i] -= 1;
  rep(i, n) num[i] = i;

  while(!flag){
    flag = true;
    rep(i, k) swap(num[x[i]], num[y[i]]);
    rep(i, n) flag &= i == num[i];
    res += 1;
  }

  cout << res << endl;

  return 0;
}
0