結果
| 問題 | No.2220 Range Insert & Point Mex |
| コンテスト | |
| ユーザー |
👑 tails
|
| 提出日時 | 2023-02-18 13:19:14 |
| 言語 | C90 (gcc 15.2.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,860 bytes |
| 記録 | |
| コンパイル時間 | 106 ms |
| コンパイル使用メモリ | 29,084 KB |
| 最終ジャッジ日時 | 2026-02-24 01:12:24 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.c: In function 'sort_aux':
main.c:16:9: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
16 | for(int i=0;i<256;++i){
| ^~~
main.c:16:9: note: use option '-std=c99', '-std=gnu99', '-std=c11' or '-std=gnu11' to compile your code
main.c:19:17: error: redefinition of 'i'
19 | for(int i=0;i<n;++i){
| ^
main.c:16:17: note: previous definition of 'i' with type 'int'
16 | for(int i=0;i<256;++i){
| ^
main.c:19:9: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
19 | for(int i=0;i<n;++i){
| ^~~
main.c:23:17: error: redefinition of 'i'
23 | for(int i=0;i<256;++i){
| ^
main.c:19:17: note: previous definition of 'i' with type 'int'
19 | for(int i=0;i<n;++i){
| ^
main.c:23:9: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
23 | for(int i=0;i<256;++i){
| ^~~
main.c:29:17: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
29 | for(int i=0;i<n;++i){
| ^~~
main.c:33:17: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
33 | for(int i=0;i<n;++i){
| ^~~
main.c: In function 'initb':
main.c:7:18: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
7 | #define rep(v,e) for(long v=0;v<e;++v)
| ^~~
main.c:53:9: note: in expansion of macro 'rep'
53 | rep(i,1<<6){
| ^~~
main.c:56:13: error: redefinition of 'i'
56 | rep(i,1<<12){
| ^
main.c:7:27: note: in definition of macro 'rep'
7 | #define rep(v,e) for(long v=0;v<e;++v)
| ^
main.c:53:13: note: previous definition of 'i' with type 'long int'
53 | rep(i,1<<6){
|
ソースコード
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#define getrp() ({char*mmap();mmap(0l,1l<<25,1,2,0,0ll);})
#define rd() ({long _v=0,_c;while(_c=*rp++-48,_c>=0)_v=_v*10+_c;_v;})
#define wt(v) ({ulong _z=v;do*--wp=_z%10+48;while(_z/=10);})
#define rep(v,e) for(long v=0;v<e;++v)
#define rrep(v,e) for(long v=e;v--;)
#define ctz __builtin_ctzl
typedef unsigned long ulong;
char wbuf[1<<25];
void sort_aux(ulong*a,ulong*b,int n,int ph){
int c[256];
for(int i=0;i<256;++i){
c[i]=0;
}
for(int i=0;i<n;++i){
++c[a[i]&255];
}
int t=0;
for(int i=0;i<256;++i){
int u=c[i];
c[i]=t;
t+=u;
}
if(ph==0){
for(int i=0;i<n;++i){
b[c[a[i]&255]++]=a[i]>>8|a[i]<<56;
}
}else{
for(int i=0;i<n;++i){
b[c[a[i]&255]++]=a[i]>>40|a[i]<<24;
}
}
}
void sort(ulong*a,int n){
ulong*b=a+n;
sort_aux(a,b,n,0);
sort_aux(b,a,n,0);
sort_aux(a,b,n,0);
sort_aux(b,a,n,1);
}
ulong e[300000*2];
ulong b0,b1[1<<6],b2[1<<12];
void initb(){
b0=~0ul;
rep(i,1<<6){
b1[i]=~0ul;
}
rep(i,1<<12){
b2[i]=~0ul;
}
}
int c[100000];
int r[100000];
int main(){
char*rp=getrp();
long n=rd();
long j=0;
rep(i,n){
long l=rd();
long r=rd();
long a=rd();
if(a<100000){
e[j++]=a<<32|l<<2|0;
e[j++]=a<<32|r<<2|2;
}
}
long q=rd();
rep(i,q){
long x=rd();
e[j++]=i<<32|x<<2|1;
}
sort(e,j);
initb();
rep(i,j){
long t=e[i]&3;
long a=e[i]>>32;
if(t==0){
if(!c[a]++){
if(!(b2[a>>6]&=~(1ul<<a))){
if(!(b1[a>>12]&=~(1ul<<(a>>6)))){
b0&=~(1ul<<(a>>12));
}
}
}
}
if(t==1){
long d=ctz(b0);
d=d<<6|ctz(b1[d]);
d=d<<6|ctz(b2[d]);
r[a]=d;
}
if(t==2){
if(!--c[a]){
b2[a>>6]|=1ul<<a;
b1[a>>12]|=1ul<<(a>>6);
b0|=1ul<<(a>>12);
}
}
}
{
char*wp=wbuf+sizeof wbuf;
rrep(i,q){
*--wp='\n';
wt(r[i]);
}
write(1,wp,wbuf+sizeof wbuf-wp);
}
_exit(0);
}
tails