結果
| 問題 | No.2042 RGB Caps |
| コンテスト | |
| ユーザー |
👑 tails
|
| 提出日時 | 2022-08-19 23:14:54 |
| 言語 | C90(gcc15) (gcc 15.2.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,317 bytes |
| 記録 | |
| コンパイル時間 | 86 ms |
| コンパイル使用メモリ | 26,712 KB |
| 最終ジャッジ日時 | 2026-02-24 01:09:50 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.c: In function 'radix_sort_aux':
main.c:14:9: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
14 | for(int i=0;i<512;++i){
| ^~~
main.c:14:9: note: use option '-std=c99', '-std=gnu99', '-std=c11' or '-std=gnu11' to compile your code
main.c:17:17: error: redefinition of 'i'
17 | for(int i=0;i<n;++i){
| ^
main.c:14:17: note: previous definition of 'i' with type 'int'
14 | for(int i=0;i<512;++i){
| ^
main.c:17:9: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
17 | for(int i=0;i<n;++i){
| ^~~
main.c:21:17: error: redefinition of 'i'
21 | for(int i=0;i<512;++i){
| ^
main.c:17:17: note: previous definition of 'i' with type 'int'
17 | for(int i=0;i<n;++i){
| ^
main.c:21:9: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
21 | for(int i=0;i<512;++i){
| ^~~
main.c:26:17: error: redefinition of 'i'
26 | for(int i=0;i<n;++i){
| ^
main.c:21:17: note: previous definition of 'i' with type 'int'
21 | for(int i=0;i<512;++i){
| ^
main.c:26:9: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
26 | for(int i=0;i<n;++i){
| ^~~
main.c: In function 'main':
main.c:5:18: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
5 | #define rep(v,e) for(long v=0;v<e;++v)
| ^~~
main.c:43:9: note: in expansion of macro 'rep'
43 | rep(i,k){
| ^~~
main.c:52:14: error: redefinition of 'i'
52 | rep3(i,1,n+1){
| ^
main.c:6:30: note: in definition of macro 'rep3'
6 | #define rep3(v,s,e) for(long v=s;v<e;++v)
| ^
main.c:43:13: note: previous definition of 'i' wit
ソースコード
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#define rd() ({long _v=0,_c;while(_c=*rp++-48,_c>=0)_v=_v*10+_c;_v;})
#define rep(v,e) for(long v=0;v<e;++v)
#define rep3(v,s,e) for(long v=s;v<e;++v)
typedef unsigned long ulong;
char*mmap();
char wbuf[1<<25];
void radix_sort_aux(unsigned*a,unsigned*b,int n){
int c[512];
for(int i=0;i<512;++i){
c[i]=0;
}
for(int i=0;i<n;++i){
++c[a[i]&511];
}
int t=0;
for(int i=0;i<512;++i){
int u=c[i];
c[i]=t;
t+=u;
}
for(int i=0;i<n;++i){
b[c[a[i]&511]++]=a[i]>>9|a[i]<<23;
}
}
void radix_sort(unsigned*a,int n){
static unsigned b[100000];
radix_sort_aux(a,b,n);
radix_sort_aux(b,a,n);
}
unsigned b[100000];
int main(){
char*rp=mmap(0l,1l<<25,1,2,0,0ll);
long n=rd();
long k=rd();
rep(i,k){
long a=rd();
long c=*rp;
rp+=2;
b[i]=c<<18|a;
}
radix_sort(b,k);
char*wp=wbuf;
long j=0;
rep3(i,1,n+1){
unsigned p='BGR';
if(b[j]>>14==i){
if((char)b[j]=='G'){
p='BRG';
}
else
if((char)b[j]=='B'){
p='GRB';
}
++j;
}
++i;
if(b[j]>>14==i){
if((char)b[j]=='G'){
if(p=='GRB') p='RGB';
}
else
if((char)b[j]=='B'){
if(p=='BRG') p='RBG';
if(p=='BGR') p='GBR';
}
++j;
}
++i;
if(b[j]>>14==i){
++j;
}
*(unsigned*)wp=p;
wp+=3;
}
write(1,wbuf,n);
_exit(0);
}
tails