結果

問題 No.3171 Color Restoration
ユーザー t98slider
提出日時 2025-02-21 01:20:04
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,104 bytes
コンパイル時間 2,583 ms
コンパイル使用メモリ 209,448 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-06-06 20:50:05
合計ジャッジ時間 4,116 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
    // サイトごとの色のテーブル
    vector<vector<string>> table = {
        {"gray","brown","green","cyan","blue","yellow","orange","red"},
        {"gray","green","blue","yellow","red"},
        {"gray","green","cyan","blue","violet","orange","red"}
    };

    // 入力を受け取る
    vector<string> S(3);
    for(auto &&str : S) cin >> str;

    // ソートする
    sort(S.begin(), S.end());

    // 順列全探索をする
    int cnt = 0;
    do {
        // 条件を満たしているかのフラグ
        bool is_satisfied = true;
        for (int i = 0; i < 3; i++) {
            // table[i] に該当するサイト内で S[i] に該当する色があるかを調べる
            if (count(table[i].begin(), table[i].end(), S[i]) == 0) {
                // 該当する色がなかった場合
                is_satisfied = false;
                break;
            }
        }
        cnt += is_satisfied;
    } while (next_permutation(S.begin(), S.end()));

    cout << (cnt == 1 ? "Yes" : "No") << '\n';
}
0