結果

問題 No.101 ぐるぐる!あみだくじ!
ユーザー tkzw_21tkzw_21
提出日時 2014-12-25 14:57:16
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 852 bytes
コンパイル時間 785 ms
コンパイル使用メモリ 81,832 KB
実行使用メモリ 7,612 KB
最終ジャッジ日時 2023-09-02 22:53:45
合計ジャッジ時間 20,479 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,372 KB
testcase_01 AC 2 ms
4,372 KB
testcase_02 AC 2 ms
4,372 KB
testcase_03 AC 2 ms
4,372 KB
testcase_04 AC 2 ms
4,372 KB
testcase_05 AC 2 ms
4,368 KB
testcase_06 AC 2 ms
4,368 KB
testcase_07 AC 1 ms
4,372 KB
testcase_08 AC 2 ms
4,368 KB
testcase_09 AC 2 ms
4,368 KB
testcase_10 AC 2 ms
4,372 KB
testcase_11 AC 1,035 ms
4,368 KB
testcase_12 AC 1,075 ms
4,372 KB
testcase_13 AC 1,010 ms
4,372 KB
testcase_14 AC 1,544 ms
4,372 KB
testcase_15 AC 101 ms
4,368 KB
testcase_16 AC 124 ms
4,372 KB
testcase_17 AC 144 ms
4,372 KB
testcase_18 AC 179 ms
4,368 KB
testcase_19 AC 208 ms
4,368 KB
testcase_20 AC 10 ms
4,368 KB
testcase_21 AC 8 ms
4,372 KB
testcase_22 AC 321 ms
4,368 KB
testcase_23 AC 167 ms
4,368 KB
testcase_24 AC 3,030 ms
4,368 KB
testcase_25 AC 2,095 ms
4,372 KB
testcase_26 AC 1,541 ms
4,372 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 <iostream>
#include <cmath>
#include <vector>
#include <utility>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <list>
#include <algorithm>
#define INF 114514

using namespace std;

typedef pair<double,double> P;

int n;
bool check(int a[100]){
	for(int i=0;i<n;i++){
		if(a[i] != i)return false;
	}
	return true;
}

int main(void){
	int k;
	cin >> n >> k;
	vector<int> x(k),y(k);
	for(int i=0;i<k;i++){
		cin >> x[i] >> y[i];
		x[i]--;y[i]--;
	}

	map<int,int> fx;
	int a[100],b[100];
	for(int i=0;i<n;i++)a[i] = i;
	for(int i=0;i<k;i++)swap(a[x[i]],a[y[i]]);

	for(int i=0;i<n;i++)fx[i] = a[i];


	int cnt = 1;
	while(!check(a)){
		memcpy(b,a,sizeof(b));
		for(int i=0;i<n;i++)a[i] = b[fx[i]];
		cnt++;

		// for(int i=0;i<n;i++)cout << a[i] << " ";
		// 	cout << endl;
	}
	cout << cnt << endl;



	return 0;
}
0