結果
| 問題 |
No.3171 Color Restoration
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-03-15 08:42:57 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,104 bytes |
| コンパイル時間 | 3,757 ms |
| コンパイル使用メモリ | 288,284 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-06-06 20:50:13 |
| 合計ジャッジ時間 | 4,477 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 |
ソースコード
#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';
}