結果
| 問題 |
No.602 隠されていたゲーム2
|
| コンテスト | |
| ユーザー |
👑 testestest
|
| 提出日時 | 2017-12-02 00:22:07 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 772 bytes |
| コンパイル時間 | 1,219 ms |
| コンパイル使用メモリ | 29,696 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-28 01:26:41 |
| 合計ジャッジ時間 | 1,877 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 WA * 5 |
コンパイルメッセージ
main.c:1:1: warning: data definition has no type or storage class
1 | ans;
| ^~~
main.c:1:1: warning: type defaults to 'int' in declaration of 'ans' [-Wimplicit-int]
main.c:2:1: warning: data definition has no type or storage class
2 | a[200000];
| ^
main.c:2:1: warning: type defaults to 'int' in declaration of 'a' [-Wimplicit-int]
main.c:3:1: warning: data definition has no type or storage class
3 | odd[200000],even[200000],oddc,evenc;
| ^~~
main.c:3:1: warning: type defaults to 'int' in declaration of 'odd' [-Wimplicit-int]
main.c:3:13: warning: type defaults to 'int' in declaration of 'even' [-Wimplicit-int]
3 | odd[200000],even[200000],oddc,evenc;
| ^~~~
main.c:3:26: warning: type defaults to 'int' in declaration of 'oddc' [-Wimplicit-int]
3 | odd[200000],even[200000],oddc,evenc;
| ^~~~
main.c:3:31: warning: type defaults to 'int' in declaration of 'evenc' [-Wimplicit-int]
3 | odd[200000],even[200000],oddc,evenc;
| ^~~~~
main.c:4:1: warning: data definition has no type or storage class
4 | n,x,y;
| ^
main.c:4:1: warning: type defaults to 'int' in declaration of 'n' [-Wimplicit-int]
main.c:4:3: warning: type defaults to 'int' in declaration of 'x' [-Wimplicit-int]
4 | n,x,y;
| ^
main.c:4:5: warning: type defaults to 'int' in declaration of 'y' [-Wimplicit-int]
4 | n,x,y;
| ^
main.c:5:1: warning: return type defaults to 'int' [-Wimplicit-int]
5 | c(int*a,int*b){return*a-*b;}
| ^
main.c:6:1: warning: return type defaults to 'int' [-Wimplicit-int]
6 | f(int x,int*a){
| ^
main.c:15:1: warning: return type defaults to 'int' [-Wimplicit-int]
15 | g(i){
| ^
main.c: In function 'g':
main.c:15:1: warning: type of 'i' defaults to 'int' [-Wimplicit-int]
main.c:16:15: warning: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
16 | int l=abs(x-a[i]),r=x+
ソースコード
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 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;
if(l%2==1){
aa=odd;
}else{
aa=even;
}
int temp=f(l,aa);
int temp2=f(r,aa);
return l==aa[temp]||temp!=temp2;
}
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,4,c);
qsort(odd,oddc,4,c);
qsort(even,evenc,4,c);
scanf("%d%d",&x,&y);
x=abs(x)+abs(y);
if(x==0){puts("0");return 0;}
if(a[f(x,a)]==x){puts("1");return 0;}
else{
for(int i=0;i<n;i++)if(g(i)){puts("2");return 0;}
}
puts("-1");
}
testestest