結果

問題 No.429 CupShuffle
ユーザー rapurasurapurasu
提出日時 2016-10-21 21:46:42
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 79 ms / 2,000 ms
コード長 927 bytes
コンパイル時間 2,898 ms
コンパイル使用メモリ 144,940 KB
実行使用メモリ 4,524 KB
最終ジャッジ日時 2023-08-15 10:27:47
合計ジャッジ時間 4,202 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 7 ms
4,376 KB
testcase_11 AC 69 ms
4,500 KB
testcase_12 AC 67 ms
4,496 KB
testcase_13 AC 73 ms
4,496 KB
testcase_14 AC 79 ms
4,524 KB
testcase_15 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:49:9: warning: ‘yy’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  int xx,yy;
         ^~
main.cpp:49:6: warning: ‘xx’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  int xx,yy;
      ^~
main.cpp:54:6: warning: ‘y’ may be used uninitialized in this function [-Wmaybe-uninitialized]
      if(B[i]==y){
      ^~
main.cpp:51:6: warning: ‘x’ may be used uninitialized in this function [-Wmaybe-uninitialized]
      if(B[i]==x){
      ^~

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
int N;
int K;
int X;
int A[100001];
int B[100001];
int C[100001];

void swap(int x,int y){
   int temp=A[x];
   A[x]=A[y];
   A[y]=temp;
}

int main(){
	cin>>N>>K>>X;
	REP(i,N){
	  A[i]=i+1;
	}
	REP(i,K){
	   if(i==X-1){
	      string s,ss;
	      cin>>s>>ss;
	      REP(i,N){
	          B[i]=A[i];
	      }
	   }else{
	      int a,b;
	      cin>>a>>b;
	      swap(a-1,b-1);
	   }	   
	}
	REP(i,N){
	   cin>>C[i];
	}
	//違う場所を探す
	int x,y,c=0;
	REP(i,N){
	    if(A[i]!=C[i]){
	       x=A[i];
	       y=C[i];
	    }
	}
	int xx,yy;
	REP(i,N){
	    if(B[i]==x){
	       xx=i+1;
	    }
	    if(B[i]==y){
	       yy=i+1;
	    }
	}
	
        cout<<min(xx,yy)<<" "<<max(xx,yy)<<endl;
	return(0);
}
0