結果
問題 | No.602 隠されていたゲーム2 |
ユーザー | testestest |
提出日時 | 2017-12-02 00:53:35 |
言語 | C (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 45 ms / 2,000 ms |
コード長 | 884 bytes |
コンパイル時間 | 357 ms |
コンパイル使用メモリ | 30,464 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-05-09 11:29:33 |
合計ジャッジ時間 | 1,431 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,816 KB |
testcase_01 | AC | 1 ms
6,940 KB |
testcase_02 | AC | 1 ms
6,940 KB |
testcase_03 | AC | 1 ms
6,944 KB |
testcase_04 | AC | 1 ms
6,940 KB |
testcase_05 | AC | 1 ms
6,944 KB |
testcase_06 | AC | 1 ms
6,940 KB |
testcase_07 | AC | 2 ms
6,944 KB |
testcase_08 | AC | 1 ms
6,940 KB |
testcase_09 | AC | 1 ms
6,940 KB |
testcase_10 | AC | 2 ms
6,940 KB |
testcase_11 | AC | 2 ms
6,940 KB |
testcase_12 | AC | 1 ms
6,940 KB |
testcase_13 | AC | 1 ms
6,940 KB |
testcase_14 | AC | 2 ms
6,940 KB |
testcase_15 | AC | 2 ms
6,944 KB |
testcase_16 | AC | 6 ms
6,940 KB |
testcase_17 | AC | 12 ms
6,940 KB |
testcase_18 | AC | 35 ms
6,944 KB |
testcase_19 | AC | 39 ms
6,940 KB |
testcase_20 | AC | 25 ms
6,944 KB |
testcase_21 | AC | 24 ms
6,944 KB |
testcase_22 | AC | 45 ms
6,944 KB |
testcase_23 | AC | 23 ms
6,940 KB |
コンパイルメッセージ
main.c:3:1: warning: return type defaults to 'int' [-Wimplicit-int] 3 | c(int*a,int*b){return*a-*b;} | ^ main.c:4:1: warning: return type defaults to 'int' [-Wimplicit-int] 4 | f(int x,int*a,int n){ | ^ main.c:13:1: warning: return type defaults to 'int' [-Wimplicit-int] 13 | g(i){ | ^ main.c: In function 'g': main.c:13:1: warning: type of 'i' defaults to 'int' [-Wimplicit-int] main.c:14:15: warning: implicit declaration of function 'abs' [-Wimplicit-function-declaration] 14 | int l=abs(x-a[i]),r=x+a[i]; | ^~~ main.c:1:1: note: include '<stdlib.h>' or provide a declaration of 'abs' +++ |+#include <stdlib.h> 1 | #define int long main.c:14:20: warning: 'abs' argument 1 type is 'long int' where 'int' is expected in a call to built-in function declared without prototype [-Wbuiltin-declaration-mismatch] 14 | int l=abs(x-a[i]),r=x+a[i]; | ~^~~~~ <built-in>: note: built-in 'abs' declared here main.c: At top level: main.c:28:1: warning: return type defaults to 'int' [-Wimplicit-int] 28 | main(){ | ^~~~ main.c: In function 'main': main.c:29:9: warning: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 29 | scanf("%d",&n); | ^~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf' +++ |+#include <stdio.h> 1 | #define int long main.c:29:9: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] 29 | scanf("%d",&n); | ^~~~~ main.c:29:9: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:35:9: warning: implicit declaration of function 'qsort' [-Wimplicit-function-declaration] 35 | qsort(a,n,sizeof(int),c); | ^~~~~ main.c:39:15: warning: 'abs' argument 1 type is 'long int' where 'int' is expected in a call to built-in function declared without prototype [-Wbuiltin-declaration-mis
ソースコード
#define int long int 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"); }