結果

問題 No.1468 Colourful Pastel
ユーザー 👑 Nachia
提出日時 2021-04-04 14:33:14
言語 C++17(gcc12)
(gcc 12.4.0 + boost 1.89.0)
コンパイル:
g++-12 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 28 ms / 1,000 ms
コード長 1,068 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 5,938 ms
コンパイル使用メモリ 335,892 KB
実行使用メモリ 12,004 KB
最終ジャッジ日時 2026-06-19 11:58:58
合計ジャッジ時間 7,354 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:43:13: warning: format not a string literal and no format arguments [-Wformat-security]
   43 |       printf(ColorsVector[t].c_str());
      |       ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #
raw source code

#include "testlib.h"
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ull=unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

set<string> ColorsSet = {
  "Red","Orange","Yellow","Green","Cyan","Blue","Violet"
};
vector<string> ColorsVector = {
  "Red","Orange","Yellow","Green","Cyan","Blue","Violet"
};

const string Heads = "ROYGCBV";
int CA[7]={};
int CB[7]={};

int main(){
  registerValidation();
  int N = inf.readInt();
  inf.readEoln();
  for(int i=0; i<N; i++){
    if(i!=0) inf.readSpace();
    string S = inf.readToken();
    assert(ColorsSet.count(S) != 0);
    CA[Heads.find(S.front())] += 1;
  }
  inf.readEoln();
  for(int i=0; i<N-1; i++){
    if(i!=0) inf.readSpace();
    string S = inf.readToken();
    assert(ColorsSet.count(S) != 0);
    CB[Heads.find(S.front())] += 1;
  }
  inf.readEoln();
  inf.readEof();
  int sumabs = 0;
  for(int t=0; t<7; t++) sumabs += abs(CA[t]-CB[t]);
  assert(sumabs==1);
  for(int t=0; t<7; t++){
    if(CA[t] != CB[t]){
      printf(ColorsVector[t].c_str());
    }
  }
  return 0;
}
0