結果

問題 No.101 ぐるぐる!あみだくじ!
ユーザー たこしたこし
提出日時 2015-11-04 14:21:35
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 872 bytes
コンパイル時間 543 ms
コンパイル使用メモリ 66,080 KB
実行使用メモリ 4,376 KB
最終ジャッジ日時 2023-10-11 13:40:27
合計ジャッジ時間 20,913 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 2 ms
4,352 KB
testcase_06 AC 1 ms
4,352 KB
testcase_07 AC 2 ms
4,352 KB
testcase_08 AC 2 ms
4,352 KB
testcase_09 AC 2 ms
4,356 KB
testcase_10 AC 2 ms
4,356 KB
testcase_11 AC 668 ms
4,348 KB
testcase_12 AC 1,222 ms
4,352 KB
testcase_13 AC 1,556 ms
4,348 KB
testcase_14 AC 1,075 ms
4,352 KB
testcase_15 AC 106 ms
4,352 KB
testcase_16 AC 152 ms
4,352 KB
testcase_17 AC 154 ms
4,352 KB
testcase_18 AC 129 ms
4,352 KB
testcase_19 AC 198 ms
4,352 KB
testcase_20 AC 7 ms
4,352 KB
testcase_21 AC 8 ms
4,348 KB
testcase_22 AC 250 ms
4,356 KB
testcase_23 AC 231 ms
4,348 KB
testcase_24 AC 1,967 ms
4,348 KB
testcase_25 AC 2,664 ms
4,352 KB
testcase_26 AC 2,201 ms
4,352 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 <vector>
#include <cstdio>
#include <string>
#include <queue>
#include <algorithm>
#include <cstring>

using namespace std;

typedef long long LL;

#define MAX_N 101
#define MAX_K 1001

int N, K;
int X[MAX_K], Y[MAX_K];

void Input(){

  cin >> N;
  cin >> K;

  for(int i = 0; i < K; i++){
    cin >> X[i] >> Y[i];
  }

}

void ExecAmida(vector<int>& AmidaList){

  for(int k = 0; k < K; k++){
    int x = X[k], y = Y[k];
    x--; y--;
    swap(AmidaList[x], AmidaList[y]);
  }

}

int Solve(){

  vector<int> InitList;
  vector<int> AmidaList;

  for(int i = 1; i <= N; i++){
    InitList.push_back(i);
    AmidaList.push_back(i);
  }

  int ret = 0;

  while(true){

    ret++;
    ExecAmida(AmidaList);

    if(InitList == AmidaList)
      break;

  }

  return ret;

}

int main(){

  Input();

  cout << Solve() << endl;

  return 0;

}
0