結果

問題 No.101 ぐるぐる!あみだくじ!
ユーザー itezpaceitezpace
提出日時 2016-11-23 07:12:52
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 743 bytes
コンパイル時間 624 ms
コンパイル使用メモリ 63,052 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-08-18 06:46:43
合計ジャッジ時間 22,441 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 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 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 152 ms
4,380 KB
testcase_12 AC 159 ms
4,380 KB
testcase_13 AC 148 ms
4,380 KB
testcase_14 AC 234 ms
4,376 KB
testcase_15 AC 15 ms
4,376 KB
testcase_16 AC 21 ms
4,380 KB
testcase_17 AC 23 ms
4,380 KB
testcase_18 AC 29 ms
4,376 KB
testcase_19 AC 32 ms
4,380 KB
testcase_20 AC 3 ms
4,376 KB
testcase_21 AC 3 ms
4,376 KB
testcase_22 AC 52 ms
4,376 KB
testcase_23 AC 26 ms
4,376 KB
testcase_24 AC 439 ms
4,376 KB
testcase_25 AC 315 ms
4,376 KB
testcase_26 AC 225 ms
4,376 KB
testcase_27 AC 3,474 ms
4,380 KB
testcase_28 AC 2,097 ms
4,376 KB
testcase_29 AC 1,903 ms
4,376 KB
testcase_30 AC 1,589 ms
4,376 KB
testcase_31 AC 1,538 ms
4,376 KB
testcase_32 AC 1,526 ms
4,380 KB
testcase_33 TLE -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:37:15: warning: ‘a’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     while(v1[a]!=v2[a]){
               ^

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
int main(){
  int N;cin>>N;
  int K;cin>>K;
  int X,Y;
  vector<int> v1(N);
  for(int i=0;i<N;++i){
    v1[i]=i+1;
  }
  vector<int> v2=v1;
  for(int i=0;i<K;++i){
    cin>>X>>Y;
    int t=v2[X-1];
    v2[X-1]=v2[Y-1];
    v2[Y-1]=t;
  }
  vector<int> v3(N);
  for(int i=0;i<N;++i){
    for(int j=0;j<N;++j){
      if(v1[i]==v2[j]){
        v3[i]=j;
        break;
      }
    }
  }
  int cnt=1;
  while(v1!=v2){
    int a;
    for(int i=0;i<N;++i){
      if(v1[i]!=v2[i]){
        a=i;
        break;
      }
    }
    while(v1[a]!=v2[a]){
      vector<int> v4(N);
      for(int i=0;i<N;++i){
        v4[v3[i]]=v2[i];
      }
      v2=v4;
      cnt++;
    }
  }
  cout<<cnt<<endl;
}
0