結果
問題 | No.2978 Lexicographically Smallest and Largest Subarray |
ユーザー | tails |
提出日時 | 2024-12-03 15:18:19 |
言語 | C90 (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 188 ms / 2,000 ms |
コード長 | 1,723 bytes |
コンパイル時間 | 385 ms |
コンパイル使用メモリ | 28,544 KB |
実行使用メモリ | 25,616 KB |
平均クエリ数 | 1499.00 |
最終ジャッジ日時 | 2024-12-03 15:18:33 |
合計ジャッジ時間 | 13,630 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 171 ms
25,196 KB |
testcase_01 | AC | 178 ms
24,812 KB |
testcase_02 | AC | 185 ms
24,556 KB |
testcase_03 | AC | 188 ms
25,196 KB |
testcase_04 | AC | 170 ms
24,812 KB |
testcase_05 | AC | 163 ms
25,196 KB |
testcase_06 | AC | 165 ms
24,940 KB |
testcase_07 | AC | 157 ms
24,824 KB |
testcase_08 | AC | 159 ms
24,568 KB |
testcase_09 | AC | 160 ms
25,124 KB |
testcase_10 | AC | 160 ms
25,208 KB |
testcase_11 | AC | 158 ms
25,208 KB |
testcase_12 | AC | 160 ms
24,824 KB |
testcase_13 | AC | 167 ms
24,824 KB |
testcase_14 | AC | 161 ms
24,824 KB |
testcase_15 | AC | 160 ms
25,208 KB |
testcase_16 | AC | 159 ms
25,208 KB |
testcase_17 | AC | 159 ms
25,196 KB |
testcase_18 | AC | 160 ms
25,208 KB |
testcase_19 | AC | 177 ms
25,196 KB |
testcase_20 | AC | 161 ms
25,208 KB |
testcase_21 | AC | 158 ms
24,824 KB |
testcase_22 | AC | 158 ms
24,568 KB |
testcase_23 | AC | 160 ms
24,812 KB |
testcase_24 | AC | 162 ms
25,208 KB |
testcase_25 | AC | 179 ms
24,824 KB |
testcase_26 | AC | 159 ms
24,824 KB |
testcase_27 | AC | 160 ms
24,824 KB |
testcase_28 | AC | 160 ms
24,824 KB |
testcase_29 | AC | 164 ms
24,568 KB |
testcase_30 | AC | 161 ms
25,208 KB |
testcase_31 | AC | 179 ms
25,208 KB |
testcase_32 | AC | 158 ms
24,824 KB |
testcase_33 | AC | 169 ms
24,952 KB |
testcase_34 | AC | 174 ms
25,592 KB |
testcase_35 | AC | 179 ms
25,464 KB |
testcase_36 | AC | 170 ms
24,580 KB |
testcase_37 | AC | 160 ms
25,208 KB |
testcase_38 | AC | 159 ms
25,208 KB |
testcase_39 | AC | 161 ms
25,208 KB |
testcase_40 | AC | 159 ms
25,208 KB |
testcase_41 | AC | 164 ms
24,568 KB |
testcase_42 | AC | 173 ms
24,824 KB |
testcase_43 | AC | 161 ms
25,208 KB |
testcase_44 | AC | 161 ms
25,208 KB |
testcase_45 | AC | 159 ms
24,824 KB |
testcase_46 | AC | 172 ms
24,580 KB |
testcase_47 | AC | 173 ms
24,580 KB |
testcase_48 | AC | 159 ms
25,616 KB |
testcase_49 | AC | 163 ms
24,580 KB |
testcase_50 | AC | 158 ms
24,568 KB |
testcase_51 | AC | 159 ms
24,580 KB |
testcase_52 | AC | 172 ms
24,836 KB |
testcase_53 | AC | 178 ms
25,220 KB |
testcase_54 | AC | 177 ms
25,220 KB |
testcase_55 | AC | 160 ms
24,836 KB |
testcase_56 | AC | 161 ms
24,580 KB |
コンパイルメッセージ
main.c: In function ‘main’: main.c:5:48: warning: implicit declaration of function ‘read’ [-Wimplicit-function-declaration] 5 | #define rd_getc() ({if(rpos>=rend){rpos=0;rend=read(0,rbuf,rbufsize);dprintf(2,"rend=%d\n",rend);}rbuf[rpos++];}) | ^~~~ main.c:6:37: note: in expansion of macro ‘rd_getc’ 6 | #define rd() ({int _v=0,_c;while(_c=rd_getc()-48,_c>=0)_v=_v*10+_c;_v;}) | ^~~~~~~ main.c:17:15: note: in expansion of macro ‘rd’ 17 | int n=rd(); // n=1000 | ^~ main.c:5:70: warning: implicit declaration of function ‘dprintf’ [-Wimplicit-function-declaration] 5 | #define rd_getc() ({if(rpos>=rend){rpos=0;rend=read(0,rbuf,rbufsize);dprintf(2,"rend=%d\n",rend);}rbuf[rpos++];}) | ^~~~~~~ main.c:6:37: note: in expansion of macro ‘rd_getc’ 6 | #define rd() ({int _v=0,_c;while(_c=rd_getc()-48,_c>=0)_v=_v*10+_c;_v;}) | ^~~~~~~ main.c:17:15: note: in expansion of macro ‘rd’ 17 | int n=rd(); // n=1000 | ^~ main.c:33:17: warning: implicit declaration of function ‘write’ [-Wimplicit-function-declaration] 33 | write(1,wbuf,wp-wbuf); | ^~~~~ main.c:105:9: warning: implicit declaration of function ‘_exit’ [-Wimplicit-function-declaration] 105 | _exit(0); | ^~~~~ main.c:105:9: warning: incompatible implicit declaration of built-in function ‘_exit’ [-Wbuiltin-declaration-mismatch]
ソースコード
#pragma GCC optimize("Ofast") #pragma GCC target("avx2") #define rbufsize 65536 #define rd_getc() ({if(rpos>=rend){rpos=0;rend=read(0,rbuf,rbufsize);dprintf(2,"rend=%d\n",rend);}rbuf[rpos++];}) #define rd() ({int _v=0,_c;while(_c=rd_getc()-48,_c>=0)_v=_v*10+_c;_v;}) #define wt(v) {unsigned _z=v,_n=0;long _d=0;while(++_n,_d=_d<<8|0x30|_z%10,_z/=10);*(long*)wp=_d;wp+=_n;} #define rep(v,e) for(typeof(e)v=0;v<e;++v) char wbuf[1<<25]; char rbuf[rbufsize]; int rpos,rend; int a[500]; int b[500]; int main(){ int n=rd(); // n=1000 int q=rd(); // q=1500 { char*wp=wbuf; rep(i,n>>1){ *wp++='?'; *wp++=' '; wt(i*2+1); *wp++=' '; wt(n); *wp++=' '; wt(i*2+2); *wp++=' '; wt(n); *wp++='\n'; } write(1,wbuf,wp-wbuf); rep(i,n>>1){ if(rd_getc()&1){ a[i]=i*2+1; b[i]=i*2+2; }else{ a[i]=i*2+2; b[i]=i*2+1; } rd_getc(); } } for(int m=n>>1;m>1;m=m+1>>1){ char*wp=wbuf; rep(i,m>>1){ *wp++='?'; *wp++=' '; wt(a[i*2+0]); *wp++=' '; wt(a[i*2+0]); *wp++=' '; wt(a[i*2+1]); *wp++=' '; wt(a[i*2+1]); *wp++='\n'; } rep(i,m>>1){ *wp++='?'; *wp++=' '; wt(b[i*2+0]); *wp++=' '; wt(n); *wp++=' '; wt(b[i*2+1]); *wp++=' '; wt(n); *wp++='\n'; } write(1,wbuf,wp-wbuf); rep(i,m>>1){ if(rd_getc()&1){ a[i]=a[i*2+0]; }else{ a[i]=a[i*2+1]; } rd_getc(); } rep(i,m>>1){ if(rd_getc()&1){ b[i]=b[i*2+1]; }else{ b[i]=b[i*2+0]; } rd_getc(); } a[m>>1]=a[m-1]; b[m>>1]=b[m-1]; } { char*wp=wbuf; *wp++='!'; *wp++=' '; wt(a[0]); *wp++=' '; wt(a[0]); *wp++=' '; wt(b[0]); *wp++=' '; wt(n); *wp++='\n'; write(1,wbuf,wp-wbuf); } _exit(0); }