結果
| 問題 | No.2978 Lexicographically Smallest and Largest Subarray |
| コンテスト | |
| ユーザー |
👑 tails
|
| 提出日時 | 2024-12-03 15:51:43 |
| 言語 | C90(gcc15) (gcc 15.2.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,707 bytes |
| 記録 | |
| コンパイル時間 | 93 ms |
| コンパイル使用メモリ | 28,968 KB |
| 最終ジャッジ日時 | 2026-02-24 01:21:21 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.c: In function 'main':
main.c:17:21: error: C++ style comments are not allowed in ISO C90
17 | int n=rd(); // n=1000
| ^
main.c:17:21: note: (this will be reported only once per input file)
main.c:21:21: error: expected ';' before 'i'
21 | rep(i,n>>1){
| ^
main.c:8:31: note: in definition of macro 'rep'
8 | #define rep(v,e) for(typeof(e)v=0;v<e;++v)
| ^
main.c:21:21: error: 'i' undeclared (first use in this function)
21 | rep(i,n>>1){
| ^
main.c:8:35: note: in definition of macro 'rep'
8 | #define rep(v,e) for(typeof(e)v=0;v<e;++v)
| ^
main.c:21:21: note: each undeclared identifier is reported only once for each function it appears in
21 | rep(i,n>>1){
| ^
main.c:8:35: note: in definition of macro 'rep'
8 | #define rep(v,e) for(typeof(e)v=0;v<e;++v)
| ^
main.c:34:21: error: expected ';' before 'i'
34 | rep(i,n>>1){
| ^
main.c:8:31: note: in definition of macro 'rep'
8 | #define rep(v,e) for(typeof(e)v=0;v<e;++v)
| ^
main.c:45:9: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
45 | for(int m=n>>1;m>1;m=m+1>>1){
| ^~~
main.c:45:9: note: use option '-std=c99', '-std=gnu99', '-std=c11' or '-std=gnu11' to compile your code
main.c:47:21: error: expected ';' before 'i'
47 | rep(i,m>>1){
| ^
main.c:8:31: note: in definition of macro 'rep'
8 | #define rep(v,e) for(typeof(e)v=0;v<e;++v)
| ^
main.c:59:21: error: expected ';' before 'i'
59 | rep(i,m>>1){
| ^
main.c:8:31: note: in definition of macro 'rep'
8 | #de
ソースコード
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#define rbufsize 4096
#define rd_getc() ({if(rpos>=rend){usleep(2000);rpos=0;rend=read(0,rbuf,rbufsize);}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);
}
tails