結果
問題 | No.619 CardShuffle |
ユーザー | %20 |
提出日時 | 2017-12-29 20:56:25 |
言語 | C (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 84 ms / 3,000 ms |
コード長 | 1,175 bytes |
コンパイル時間 | 164 ms |
コンパイル使用メモリ | 31,488 KB |
実行使用メモリ | 5,504 KB |
最終ジャッジ日時 | 2024-06-02 05:30:04 |
合計ジャッジ時間 | 3,320 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 1 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 1 ms
5,376 KB |
testcase_04 | AC | 1 ms
5,376 KB |
testcase_05 | AC | 1 ms
5,376 KB |
testcase_06 | AC | 1 ms
5,376 KB |
testcase_07 | AC | 1 ms
5,376 KB |
testcase_08 | AC | 1 ms
5,376 KB |
testcase_09 | AC | 1 ms
5,376 KB |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 1 ms
5,376 KB |
testcase_12 | AC | 1 ms
5,376 KB |
testcase_13 | AC | 1 ms
5,376 KB |
testcase_14 | AC | 0 ms
5,376 KB |
testcase_15 | AC | 1 ms
5,376 KB |
testcase_16 | AC | 84 ms
5,376 KB |
testcase_17 | AC | 67 ms
5,376 KB |
testcase_18 | AC | 78 ms
5,376 KB |
testcase_19 | AC | 67 ms
5,376 KB |
testcase_20 | AC | 67 ms
5,376 KB |
testcase_21 | AC | 76 ms
5,376 KB |
testcase_22 | AC | 60 ms
5,376 KB |
testcase_23 | AC | 75 ms
5,376 KB |
testcase_24 | AC | 58 ms
5,504 KB |
testcase_25 | AC | 63 ms
5,376 KB |
testcase_26 | AC | 83 ms
5,376 KB |
testcase_27 | AC | 73 ms
5,376 KB |
testcase_28 | AC | 81 ms
5,376 KB |
testcase_29 | AC | 73 ms
5,376 KB |
testcase_30 | AC | 74 ms
5,376 KB |
testcase_31 | AC | 1 ms
5,376 KB |
testcase_32 | AC | 68 ms
5,376 KB |
testcase_33 | AC | 76 ms
5,376 KB |
testcase_34 | AC | 74 ms
5,376 KB |
testcase_35 | AC | 35 ms
5,376 KB |
コンパイルメッセージ
main.c:1:7: warning: type defaults to 'int' in declaration of 'mod' [-Wimplicit-int] 1 | const mod=1000000007; | ^~~ main.c:9:1: warning: data definition has no type or storage class 9 | idx[1<<17]; | ^~~ main.c:9:1: warning: type defaults to 'int' in declaration of 'idx' [-Wimplicit-int] main.c:10:1: warning: data definition has no type or storage class 10 | CN; | ^~ main.c:10:1: warning: type defaults to 'int' in declaration of 'CN' [-Wimplicit-int] main.c:11:1: warning: data definition has no type or storage class 11 | N,Q,X,Y,x,y; | ^ main.c:11:1: warning: type defaults to 'int' in declaration of 'N' [-Wimplicit-int] main.c:11:3: warning: type defaults to 'int' in declaration of 'Q' [-Wimplicit-int] 11 | N,Q,X,Y,x,y; | ^ main.c:11:5: warning: type defaults to 'int' in declaration of 'X' [-Wimplicit-int] 11 | N,Q,X,Y,x,y; | ^ main.c:11:7: warning: type defaults to 'int' in declaration of 'Y' [-Wimplicit-int] 11 | N,Q,X,Y,x,y; | ^ main.c:11:9: warning: type defaults to 'int' in declaration of 'x' [-Wimplicit-int] 11 | N,Q,X,Y,x,y; | ^ main.c:11:11: warning: type defaults to 'int' in declaration of 'y' [-Wimplicit-int] 11 | N,Q,X,Y,x,y; | ^ main.c:45:1: warning: return type defaults to 'int' [-Wimplicit-int] 45 | d(i){ | ^ main.c: In function 'd': main.c:45:1: warning: type of 'i' defaults to 'int' [-Wimplicit-int] main.c:49:25: warning: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 49 | scanf("%c%*c",&C[i].o); | ^~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf' +++ |+#include <stdio.h> 1 | const mod=1000000007; main.c:49:25: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] 49 | scanf("%c%*c",&C[i].o); | ^~~~
ソースコード
const mod=1000000007; typedef struct{ long long a,b,c; char o; }abc; abc C[1<<18],t,u; idx[1<<17]; CN; N,Q,X,Y,x,y; char T; abc op(char o,abc A,abc B){ abc R; if(o){ if(A.b>=0){ if(B.b>=0){ R.a=A.a; R.b=(A.b+A.c*B.a+B.b)%mod; R.c=B.c; }else{ R.a=A.a; R.b=A.b; R.c=A.c*B.a%mod; } }else{ if(B.b>=0){ R.a=A.c*B.a%mod; R.b=B.b; R.c=B.c; }else{ R.b=-(R.c=R.a=A.c*B.a%mod); } } }else{ R.a=A.a; R.b=(A.b+A.c+B.a+B.b)%mod; R.c=B.c; } R.o=o; return R; } d(i){ if(i<65536){ d(i*2); if(CN<N){ scanf("%c%*c",&C[i].o); C[idx[++CN]=i].o^='+'; d(i*2+1); } C[i]=op(C[i].o,C[i*2],C[i*2+1]); }else{ scanf("%lld%*c",&C[i].a); C[idx[++CN]=i].b=-(C[i].c=C[i].a); } } r(i){ C[i]=op(C[i].o,C[i*2],C[i*2+1]); i&&r(i/2); } main(){ d(scanf("%d%*c",&N)); for(scanf("%d%*c",&Q);~scanf("%c%d%d%*c",&T,&X,&Y);){ t=C[x=idx[X]]; u=C[y=idx[Y]]; if(T=='!'){ C[x]=u; C[y]=t; r(x>>X%2); r(y>>Y%2); }else{ for(;x/2<y/2;x/=2,y/=2){ t=x%2?t:op(C[x/2].o,t,C[x+1]); u=y%2?op(C[y/2].o,C[y-1],u):u; } t=op(C[x/2].o,t,u); printf("%lld\n",(t.a+t.b+t.c)%mod); } } }