結果
| 問題 |
No.1468 Colourful Pastel
|
| ユーザー |
Nachia
|
| 提出日時 | 2021-04-04 14:47:57 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 1,000 ms |
| コード長 | 716 bytes |
| コンパイル時間 | 245 ms |
| コンパイル使用メモリ | 28,928 KB |
| 最終ジャッジ日時 | 2025-01-20 11:11:15 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:27:27: warning: format not a string literal and no format arguments [-Wformat-security]
27 | rep(t,7) if(C[t]) printf(Colors2[t]);
| ~~~~~~^~~~~~~~~~~~
main.cpp: In function ‘int getColorIdx(char)’:
main.cpp:9:62: warning: control reaches end of non-void function [-Wreturn-type]
9 | int getColorIdx(char c){ rep(t,7) if(Colors[t]==c) return t; }
| ^
ソースコード
#include <stdio.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define READ_A_CHAR getchar_unlocked
const char Colors[] = "ROYGCBV";
const char* Colors2[] = {"Red\n","Orange\n","Yellow\n","Green\n","Cyan\n","Blue\n","Violet\n"};
int getColorIdx(char c){ rep(t,7) if(Colors[t]==c) return t; }
int main(){
int N=0;
char c;
while((c=READ_A_CHAR())!='\n') N=N*10+(c-'0');
int C[7]={};
rep(i,N-1){
++C[getColorIdx(READ_A_CHAR())];
while(READ_A_CHAR()!=' ');
}
++C[getColorIdx(READ_A_CHAR())];
while(READ_A_CHAR()!='\n');
rep(i,N-2){
--C[getColorIdx(READ_A_CHAR())];
while(READ_A_CHAR()!=' ');
}
--C[getColorIdx(READ_A_CHAR())];
rep(t,7) if(C[t]) printf(Colors2[t]);
return 0;
}
Nachia