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