結果
問題 | No.2978 Lexicographically Smallest and Largest Subarray |
ユーザー | tails |
提出日時 | 2024-12-03 15:23:41 |
言語 | C90 (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 165 ms / 2,000 ms |
コード長 | 1,736 bytes |
コンパイル時間 | 265 ms |
コンパイル使用メモリ | 28,416 KB |
実行使用メモリ | 25,436 KB |
平均クエリ数 | 1499.00 |
最終ジャッジ日時 | 2024-12-03 15:23:55 |
合計ジャッジ時間 | 12,619 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 154 ms
25,196 KB |
testcase_01 | AC | 151 ms
25,196 KB |
testcase_02 | AC | 165 ms
25,196 KB |
testcase_03 | AC | 163 ms
25,436 KB |
testcase_04 | AC | 158 ms
25,324 KB |
testcase_05 | AC | 158 ms
25,196 KB |
testcase_06 | AC | 160 ms
25,196 KB |
testcase_07 | AC | 152 ms
24,824 KB |
testcase_08 | AC | 151 ms
24,568 KB |
testcase_09 | AC | 152 ms
24,824 KB |
testcase_10 | AC | 157 ms
24,952 KB |
testcase_11 | AC | 152 ms
25,208 KB |
testcase_12 | AC | 154 ms
25,208 KB |
testcase_13 | AC | 152 ms
25,208 KB |
testcase_14 | AC | 152 ms
24,824 KB |
testcase_15 | AC | 154 ms
25,208 KB |
testcase_16 | AC | 154 ms
24,568 KB |
testcase_17 | AC | 151 ms
25,208 KB |
testcase_18 | AC | 157 ms
25,208 KB |
testcase_19 | AC | 151 ms
25,208 KB |
testcase_20 | AC | 155 ms
24,568 KB |
testcase_21 | AC | 153 ms
25,208 KB |
testcase_22 | AC | 153 ms
24,824 KB |
testcase_23 | AC | 150 ms
25,196 KB |
testcase_24 | AC | 154 ms
24,952 KB |
testcase_25 | AC | 155 ms
24,824 KB |
testcase_26 | AC | 151 ms
25,208 KB |
testcase_27 | AC | 154 ms
24,824 KB |
testcase_28 | AC | 154 ms
24,568 KB |
testcase_29 | AC | 153 ms
24,824 KB |
testcase_30 | AC | 154 ms
25,208 KB |
testcase_31 | AC | 157 ms
24,568 KB |
testcase_32 | AC | 155 ms
25,196 KB |
testcase_33 | AC | 154 ms
24,568 KB |
testcase_34 | AC | 153 ms
25,208 KB |
testcase_35 | AC | 153 ms
24,568 KB |
testcase_36 | AC | 155 ms
25,076 KB |
testcase_37 | AC | 158 ms
24,952 KB |
testcase_38 | AC | 151 ms
24,824 KB |
testcase_39 | AC | 152 ms
25,196 KB |
testcase_40 | AC | 155 ms
24,824 KB |
testcase_41 | AC | 152 ms
24,824 KB |
testcase_42 | AC | 153 ms
25,052 KB |
testcase_43 | AC | 153 ms
25,208 KB |
testcase_44 | AC | 152 ms
25,208 KB |
testcase_45 | AC | 155 ms
24,568 KB |
testcase_46 | AC | 153 ms
24,836 KB |
testcase_47 | AC | 156 ms
25,220 KB |
testcase_48 | AC | 155 ms
25,208 KB |
testcase_49 | AC | 158 ms
25,220 KB |
testcase_50 | AC | 153 ms
25,220 KB |
testcase_51 | AC | 154 ms
24,836 KB |
testcase_52 | AC | 151 ms
25,220 KB |
testcase_53 | AC | 151 ms
24,836 KB |
testcase_54 | AC | 152 ms
24,580 KB |
testcase_55 | AC | 152 ms
24,836 KB |
testcase_56 | AC | 152 ms
25,220 KB |
コンパイルメッセージ
main.c: In function ‘main’: main.c:5:36: warning: implicit declaration of function ‘usleep’ [-Wimplicit-function-declaration] 5 | #define rd_getc() ({if(rpos>=rend){usleep(1000);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:61: warning: implicit declaration of function ‘read’ [-Wimplicit-function-declaration] 5 | #define rd_getc() ({if(rpos>=rend){usleep(1000);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:83: warning: implicit declaration of function ‘dprintf’ [-Wimplicit-function-declaration] 5 | #define rd_getc() ({if(rpos>=rend){usleep(1000);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
ソースコード
#pragma GCC optimize("Ofast") #pragma GCC target("avx2") #define rbufsize 65536 #define rd_getc() ({if(rpos>=rend){usleep(1000);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); }