結果
| 問題 |
No.2809 Sort Query
|
| コンテスト | |
| ユーザー |
tails
|
| 提出日時 | 2024-07-19 16:40:21 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
AC
|
| 実行時間 | 1,257 ms / 2,000 ms |
| コード長 | 1,853 bytes |
| コンパイル時間 | 599 ms |
| コンパイル使用メモリ | 29,340 KB |
| 実行使用メモリ | 316,288 KB |
| 最終ジャッジ日時 | 2024-07-19 16:41:19 |
| 合計ジャッジ時間 | 55,894 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 71 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:101:9: warning: implicit declaration of function ‘write’ [-Wimplicit-function-declaration]
101 | write(1,wbuf,wp-wbuf);
| ^~~~~
main.c:102:9: warning: implicit declaration of function ‘_exit’ [-Wimplicit-function-declaration]
102 | _exit(0);
| ^~~~~
main.c:102:9: warning: incompatible implicit declaration of built-in function ‘_exit’ [-Wbuiltin-declaration-mismatch]
ソースコード
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#define rd_init() char*rp=({char*mmap();mmap(0l,1l<<25,1,2,0,0ll);})
#define rd() ({int _v=0,_c;while(_c=*rp++-48,_c>=0)_v=_v*10+_c;_v;})
#define rd_long() ({long _v=0,_c;while(_c=*rp++-48,_c>=0)_v=_v*10+_c;_v;})
#define WTHI(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 WTLO(v) {unsigned _z=v,_n=8;long _d=0;while(_d=_d<<8|0x30|_z%10,_z/=10,--_n);*(long*)wp=_d;wp+=8;}
#define wt(v) if(v>=100000000){if(v>=10000000000000000l){WTHI(v/10000000000000000l);WTLO(v/100000000%100000000);}else WTHI(v/100000000);WTLO(v%100000000);}else{WTHI(v);}
#define rep(v,e) for(typeof(e)v=0;v<e;++v)
#define times(e) for(typeof(e)_=e;_--;)
typedef unsigned long ulong;
char wbuf[1<<25];
long av[300000];
int at[300000];
int l2;
long aa[900000];
int an;
struct{
int n,c[2];
}ns[600000*64];
int nn;
long kth(int k){
long x=0;
if(at[k]<=l2){
int j=0;
times(64){
x<<=1;
int c0=ns[j].c[0];
int c1=ns[j].c[1];
if(c0&&k<ns[c0].n){
j=c0;
}else{
if(c0)k-=ns[c0].n;
j=c1;
x|=1;
}
}
}else{
x=av[k];
}
return x;
}
int main(){
char*wp=wbuf;
rd_init();
int n=rd();
int q=rd();
rep(k,n){
long x=rd_long();
aa[an++]=x;
av[k]=x;
}
l2=-1;
nn=1;
rep(qi,q){
int t=*rp;
rp+=2;
if(t=='1'){
int k=rd()-1;
long x=rd_long();
aa[an++]=-kth(k);
aa[an++]=x;
av[k]=x;
at[k]=qi;
}
if(t=='2'){
rep(i,an){
long x=aa[i];
int d=1;
if(x<0){
x=-x;
d=-1;
}
int j=0;
times(64){
int ci=x<0;
if(ns[j].c[ci]==0){
ns[j].c[ci]=nn++;
}
j=ns[j].c[ci];
ns[j].n+=d;
x<<=1;
}
}
an=0;
l2=qi;
}
if(t=='3'){
int k=rd()-1;
long x=kth(k);
wt((ulong)x);
*wp++='\n';
}
}
write(1,wbuf,wp-wbuf);
_exit(0);
}
tails