結果

問題 No.429 CupShuffle
ユーザー BantakoBantako
提出日時 2017-07-25 23:55:53
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 747 bytes
コンパイル時間 1,451 ms
コンパイル使用メモリ 158,324 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-17 23:40:31
合計ジャッジ時間 2,522 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 2 ms
5,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 5 ms
5,376 KB
testcase_11 AC 28 ms
5,376 KB
testcase_12 WA -
testcase_13 AC 27 ms
5,376 KB
testcase_14 AC 27 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:2:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
    2 | main(){
      | ^~~~
main.cpp: In function ‘int main()’:
main.cpp:9:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |     scanf("%d%d%d",&N,&K,&X);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
main.cpp:11:25: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |         if(i+1==X){scanf("%*s%*s");continue;}
      |                    ~~~~~^~~~~~~~~~
main.cpp:12:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |         scanf("%d%d",&A[i],&B[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~
main.cpp:15:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   15 |         scanf("%d",&last[i]);
      |         ~~~~~^~~~~~~~~~~~~~~

ソースコード

diff #

#include<bits/stdc++.h>
main(){
    int first[100000],last[100000];
    for(int i = 0;i < 100000;i++){
        first[i] = i+1;
    }
    int N,K,X;
    int A[100000],B[100000];
    scanf("%d%d%d",&N,&K,&X);
    for(int i = 0;i < K;i++){
        if(i+1==X){scanf("%*s%*s");continue;}
        scanf("%d%d",&A[i],&B[i]);
    }
    for(int i = 0;i < N;i++){
        scanf("%d",&last[i]);
    }
    //
    using std::swap;
    for(int i = 0;i < X-1;i++){
        swap(first[A[i]-1],first[B[i]-1]);
    }
    for(int i = K-1;i > X;i--){
        std::swap(last[A[i]-1],last[B[i]-1]);
    }
    int p[2] = {0,0};
    for(int i = 0;i < N;i++){
        if(first[i]!=last[i]){
            p[p[0]?1:0] = i+1;
        }
    }
    printf("%d %d\n",p[0],p[1]);
}
0