結果

問題 No.101 ぐるぐる!あみだくじ!
ユーザー goodbatongoodbaton
提出日時 2015-08-08 01:45:53
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,111 bytes
コンパイル時間 480 ms
コンパイル使用メモリ 71,568 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-25 06:38:53
合計ジャッジ時間 24,163 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 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 155 ms
4,376 KB
testcase_12 AC 161 ms
4,380 KB
testcase_13 AC 159 ms
4,376 KB
testcase_14 AC 225 ms
4,376 KB
testcase_15 AC 17 ms
4,376 KB
testcase_16 AC 20 ms
4,380 KB
testcase_17 AC 23 ms
4,376 KB
testcase_18 AC 28 ms
4,376 KB
testcase_19 AC 32 ms
4,376 KB
testcase_20 AC 3 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 50 ms
4,380 KB
testcase_23 AC 27 ms
4,380 KB
testcase_24 AC 450 ms
4,380 KB
testcase_25 AC 308 ms
4,380 KB
testcase_26 AC 227 ms
4,380 KB
testcase_27 AC 3,514 ms
4,376 KB
testcase_28 AC 2,109 ms
4,376 KB
testcase_29 AC 1,965 ms
4,380 KB
testcase_30 AC 1,613 ms
4,380 KB
testcase_31 AC 1,564 ms
4,380 KB
testcase_32 AC 1,571 ms
4,376 KB
testcase_33 TLE -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstring>

typedef long long ll;
using namespace std;

#define mod 1000000007
#define INF 1000000000
#define LLINF 2000000000000000000LL
#define PI 3.1415926536

#define SIZE 1000

int main(){
    int n,k,x[SIZE],y[SIZE];
    int num[101],check[2][101];
    bool f;
    
    scanf("%d%d",&n,&k);
    
    for(int i=1;i<=n;i++){
        num[i]=i;
        check[0][i]=i;
    }
    
    for(int i=0;i<k;i++){
        scanf("%d%d",&x[i],&y[i]);
        swap(num[x[i]],num[y[i]]);
    }
    
    for(int i=1;;i++){
        f = true;
        
        for(int i=1;i<=n;i++){
            check[1][num[i]] = check[0][i];
        }
        
        for(int i=1;i<=n;i++){
            check[0][i]=check[1][i];
            if(check[0][i]!=i)
                f = false;
        }
        
        if(f){
            printf("%d\n",i);
            return 0;
        }
        
        
    }
    
    
    
    return 0;
}
0