結果

問題 No.602 隠されていたゲーム2
ユーザー testestesttestestest
提出日時 2017-12-02 00:52:58
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 883 bytes
コンパイル時間 256 ms
コンパイル使用メモリ 30,720 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-06 00:27:47
合計ジャッジ時間 1,007 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 0 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 1 ms
5,376 KB
testcase_08 WA -
testcase_09 AC 0 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 5 ms
5,376 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 23 ms
5,376 KB
testcase_21 AC 23 ms
5,376 KB
testcase_22 WA -
testcase_23 AC 21 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:2:1: warning: data definition has no type or storage class
    2 | ans;
      | ^~~
main.c:2:1: warning: type defaults to 'int' in declaration of 'ans' [-Wimplicit-int]
main.c:3:1: warning: data definition has no type or storage class
    3 | a[200000];
      | ^
main.c:3:1: warning: type defaults to 'int' in declaration of 'a' [-Wimplicit-int]
main.c:4:1: warning: data definition has no type or storage class
    4 | odd[200000],even[200000],oddc,evenc;
      | ^~~
main.c:4:1: warning: type defaults to 'int' in declaration of 'odd' [-Wimplicit-int]
main.c:4:13: warning: type defaults to 'int' in declaration of 'even' [-Wimplicit-int]
    4 | odd[200000],even[200000],oddc,evenc;
      |             ^~~~
main.c:4:26: warning: type defaults to 'int' in declaration of 'oddc' [-Wimplicit-int]
    4 | odd[200000],even[200000],oddc,evenc;
      |                          ^~~~
main.c:4:31: warning: type defaults to 'int' in declaration of 'evenc' [-Wimplicit-int]
    4 | odd[200000],even[200000],oddc,evenc;
      |                               ^~~~~
main.c:5:1: warning: data definition has no type or storage class
    5 | n,x,y;
      | ^
main.c:5:1: warning: type defaults to 'int' in declaration of 'n' [-Wimplicit-int]
main.c:5:3: warning: type defaults to 'int' in declaration of 'x' [-Wimplicit-int]
    5 | n,x,y;
      |   ^
main.c:5:5: warning: type defaults to 'int' in declaration of 'y' [-Wimplicit-int]
    5 | n,x,y;
      |     ^
main.c:6:1: warning: return type defaults to 'int' [-Wimplicit-int]
    6 | c(int*a,int*b){return*a-*b;}
      | ^
main.c:7:1: warning: return type defaults to 'int' [-Wimplicit-int]
    7 | f(int x,int*a,int n){
      | ^
main.c:16:1: warning: return type defaults to 'int' [-Wimplicit-int]
   16 | g(i){
      | ^
main.c: In function 'g':
main.c:16:1: warning: type of 'i' defaults to 'int' [-Wimplicit-int]
main.c:17:15: warning: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
   17 |         int l=abs(x-a[i]

ソースコード

diff #

#define int long
ans;
a[200000];
odd[200000],even[200000],oddc,evenc;
n,x,y;
c(int*a,int*b){return*a-*b;}
f(int x,int*a,int n){
	int l=0,r=n;
	while(r-l>1){
		int m=(l+r)/2;
		if(a[m]>x)r=m;
		else l=m;
	}
	return l;
}
g(i){
	int l=abs(x-a[i]),r=x+a[i];
	//l以上r以下があればok
	int *aa;
	int nn;
	if(l%2==1){
		aa=odd;
		nn=oddc;
	}else{
		aa=even;
		nn=evenc;
	}
	int temp=f(l,aa,nn);
	return l<=aa[temp]&&aa[temp]<=r||temp+1<nn&&l<=aa[temp+1]&&aa[temp+1]<=r;
}
main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",a+i);
		if(a[i]%2==1)odd[oddc++]=a[i];
		else even[evenc++]=a[i];
	}
	qsort(a,n,sizeof(int),c);
	qsort(odd,oddc,sizeof(int),c);
	qsort(even,evenc,sizeof(int),c);
	scanf("%d%d",&x,&y);
	x=abs(x)+abs(y);
	if(x==0){puts("0");return 0;}
	if(a[f(x,a,n)]==x){puts("1");return 0;}
	else{
		for(int i=0;i<n;i++)if(g(i)){puts("2");return 0;}
	}
	puts("-1");
}
0