結果

問題 No.101 ぐるぐる!あみだくじ!
ユーザー basscl_sugibasscl_sugi
提出日時 2017-07-25 18:32:52
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 671 bytes
コンパイル時間 157 ms
コンパイル使用メモリ 24,704 KB
実行使用メモリ 8,220 KB
最終ジャッジ日時 2024-04-17 23:31:58
合計ジャッジ時間 16,318 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 0 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 0 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 100 ms
5,376 KB
testcase_12 AC 105 ms
5,376 KB
testcase_13 AC 95 ms
5,376 KB
testcase_14 AC 146 ms
5,376 KB
testcase_15 AC 10 ms
5,376 KB
testcase_16 AC 13 ms
5,376 KB
testcase_17 AC 14 ms
5,376 KB
testcase_18 AC 18 ms
5,376 KB
testcase_19 AC 21 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 32 ms
5,376 KB
testcase_23 AC 17 ms
5,376 KB
testcase_24 AC 295 ms
5,376 KB
testcase_25 AC 202 ms
5,376 KB
testcase_26 AC 146 ms
5,376 KB
testcase_27 AC 2,284 ms
5,376 KB
testcase_28 AC 1,379 ms
5,376 KB
testcase_29 AC 1,260 ms
5,376 KB
testcase_30 AC 1,047 ms
5,376 KB
testcase_31 AC 1,026 ms
5,376 KB
testcase_32 AC 1,016 ms
5,376 KB
testcase_33 TLE -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:13:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |     scanf("%d%d",&n,&k);
      |     ~~~~~^~~~~~~~~~~~~~
main.cpp:15:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   15 |         scanf("%d%d",&x,&y);
      |         ~~~~~^~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void){
    int i,count=1;
    int origin[100],rule[100],before[100],after[100];
    for(i=0;i<100;i++){
        origin[i]=i;
        rule[i]=i;
        before[i]=i;
    }
    int n,k,x,y,tmp;
    scanf("%d%d",&n,&k);
    for(i=0;i<k;i++){
        scanf("%d%d",&x,&y);
        tmp=rule[y-1];
        rule[y-1]=rule[x-1];
        rule[x-1]=tmp;
    }
    while(1){
        for(i=0;i<n;i++){
            after[i]=before[rule[i]];
        }
        if(memcmp(after,origin,4*n)==0){
            printf("%d\n",count);
            return 0;
        }
        memcpy(before,after,4*n);
        count++;
    }
}
0