結果

問題 No.3171 Color Restoration
ユーザー forest3
提出日時 2025-06-19 16:34:19
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 680 bytes
コンパイル時間 2,256 ms
コンパイル使用メモリ 176,880 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-06-19 16:34:23
合計ジャッジ時間 3,544 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define rep(i, a, b) for (int i = a; i < b; i++)
using ll = long long;

int main(){
	vector<string> s(3);
	rep(i, 0, 3) cin >> s[i];
	vector<vector<string>> v{
		{"gray","brown","green","cyan","blue","yellow","orange","red"},
		{"gray","green","blue","yellow","red"},
		{"gray","green","cyan","blue","violet","orange","red"},
	};
	sort(s.begin(), s.end());
	int a = 0;
	do {
		vector<int> c(3);
		rep(i, 0, 3) {
			for(auto e : v[i]) {
				if(s[i] == e) c[i]++;
			}
		}
		if(c[0] == 1 && c[1] == 1 && c[2] == 1) a++;
	} while(next_permutation(s.begin(), s.end()));
	string ans = "No";
	if(a == 1) ans = "Yes";
	cout << ans << endl;
}
0