結果
問題 | No.2042 RGB Caps |
ユーザー | tails |
提出日時 | 2022-08-19 23:14:54 |
言語 | C90 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 1,317 bytes |
コンパイル時間 | 537 ms |
コンパイル使用メモリ | 25,344 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-04-27 20:35:45 |
合計ジャッジ時間 | 1,595 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,816 KB |
testcase_01 | AC | 1 ms
6,940 KB |
testcase_02 | AC | 0 ms
6,944 KB |
testcase_03 | AC | 0 ms
6,940 KB |
testcase_04 | AC | 0 ms
6,944 KB |
testcase_05 | AC | 0 ms
6,940 KB |
testcase_06 | AC | 0 ms
6,940 KB |
testcase_07 | AC | 1 ms
6,944 KB |
testcase_08 | AC | 2 ms
6,940 KB |
testcase_09 | AC | 1 ms
6,944 KB |
testcase_10 | AC | 3 ms
6,940 KB |
testcase_11 | AC | 1 ms
6,940 KB |
testcase_12 | AC | 3 ms
6,940 KB |
testcase_13 | AC | 3 ms
6,940 KB |
testcase_14 | AC | 4 ms
6,944 KB |
testcase_15 | AC | 1 ms
6,940 KB |
testcase_16 | AC | 1 ms
6,940 KB |
testcase_17 | AC | 1 ms
6,940 KB |
コンパイルメッセージ
main.c: In function ‘main’: main.c:53:28: warning: multi-character character constant [-Wmultichar] 53 | unsigned p='BGR'; | ^~~~~ main.c:56:35: warning: multi-character character constant [-Wmultichar] 56 | p='BRG'; | ^~~~~ main.c:60:35: warning: multi-character character constant [-Wmultichar] 60 | p='GRB'; | ^~~~~ main.c:67:39: warning: multi-character character constant [-Wmultichar] 67 | if(p=='GRB') p='RGB'; | ^~~~~ main.c:67:48: warning: multi-character character constant [-Wmultichar] 67 | if(p=='GRB') p='RGB'; | ^~~~~ main.c:71:39: warning: multi-character character constant [-Wmultichar] 71 | if(p=='BRG') p='RBG'; | ^~~~~ main.c:71:48: warning: multi-character character constant [-Wmultichar] 71 | if(p=='BRG') p='RBG'; | ^~~~~ main.c:72:39: warning: multi-character character constant [-Wmultichar] 72 | if(p=='BGR') p='GBR'; | ^~~~~ main.c:72:48: warning: multi-character character constant [-Wmultichar] 72 | if(p=='BGR') p='GBR'; | ^~~~~ main.c:84:9: warning: implicit declaration of function ‘write’ [-Wimplicit-function-declaration] 84 | write(1,wbuf,n); | ^~~~~ main.c:85:9: warning: implicit declaration of function ‘_exit’ [-Wimplicit-function-declaration] 85 | _exit(0); | ^~~~~ main.c:85:9: warning: incom
ソースコード
#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); }