結果

問題 No.429 CupShuffle
ユーザー fjafjafjafjafjafja
提出日時 2017-09-10 22:17:51
言語 Java21
(openjdk 21)
結果
AC  
実行時間 910 ms / 2,000 ms
コード長 1,020 bytes
コンパイル時間 3,199 ms
コンパイル使用メモリ 75,728 KB
実行使用メモリ 70,228 KB
最終ジャッジ日時 2023-08-07 09:08:59
合計ジャッジ時間 10,680 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 215 ms
60,056 KB
testcase_01 AC 147 ms
56,792 KB
testcase_02 AC 153 ms
56,740 KB
testcase_03 AC 155 ms
56,752 KB
testcase_04 AC 215 ms
60,676 KB
testcase_05 AC 149 ms
56,760 KB
testcase_06 AC 222 ms
60,452 KB
testcase_07 AC 220 ms
59,532 KB
testcase_08 AC 159 ms
56,856 KB
testcase_09 AC 217 ms
59,692 KB
testcase_10 AC 430 ms
60,628 KB
testcase_11 AC 878 ms
68,704 KB
testcase_12 AC 881 ms
66,832 KB
testcase_13 AC 910 ms
68,896 KB
testcase_14 AC 891 ms
70,228 KB
testcase_15 AC 149 ms
56,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder;

import java.util.Scanner;

public class N429 {

	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt(),K=sc.nextInt(),X=sc.nextInt();
		int[] h=new int[N],hh=new int[N];
		int[] a=new int[K],b=new int[K];
		for(int i=0;i<N;i++)
		{
			h[i]=i+1;
		}
		for(int i=0;i<X-1;i++)
		{
			a[i]=sc.nextInt();b[i]=sc.nextInt();
		}
		String[] buf=new String[2];
		buf[0]=sc.next();buf[1]=sc.next();
	//	String buf=sc.next();
		for(int i=X;i<K;i++)
		{
			a[i]=sc.nextInt();b[i]=sc.nextInt();
		}

		for(int i=0;i<N;i++)
		{
			hh[i]=sc.nextInt();
		}

		for(int i=0;i<X-1;i++)
		{
			swap(h,a[i]-1,b[i]-1);
		}
		for(int i=K-1;i>=X;i--)
		{
			swap(hh,a[i]-1,b[i]-1);
		}

		int[] ans=new int[2];
		int p=-1;
		for(int i=0;i<N;i++)
		{
			if(h[i]!=hh[i]&&p==-1){ans[0]=i+1;p=h[i];}
			if(p==hh[i]){ans[1]=i+1;break;}
		}

		System.out.println(ans[0]+" "+ans[1]);

	}



	static void swap(int[] h,int n1,int n2)
	{
		int buf=h[n1];
		h[n1]=h[n2];
		h[n2]=buf;
	}

}
0