結果

問題 No.3171 Color Restoration
ユーザー daiota
提出日時 2025-06-06 22:52:25
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,691 bytes
コンパイル時間 2,117 ms
コンパイル使用メモリ 185,188 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-06-06 22:52:29
合計ジャッジ時間 3,341 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(ll i=0;i<ll(n);i++)











int main(void){
	cin.tie(nullptr);  ios_base::sync_with_stdio(false);
	ll i,j,k;



	vector<string> n={"gray","brown","green","cyan","blue","yellow","orange","red"};
	vector<string> w={"gray","green","blue","yellow","red"};
	vector<string> h={"gray","green","cyan","blue","violet","orange","red"};



	map<string,vector<ll>> m;
	REP(i,8) m[n[i]].push_back(1);
	REP(i,5) m[w[i]].push_back(2);
	REP(i,7) m[h[i]].push_back(3);



	string s1,s2,s3;
	cin >> s1 >> s2 >> s3;

	if(s1==s2 && s2==s3){
		if(m[s1].size()==3){
			cout << "Yes" << endl;
			return 0;
		}
	}


	if(s1==s2){
		if(m[s1].size()==2 && m[s3].size()==1){
			set<ll> s;
			s.insert(m[s1][0]);
			s.insert(m[s1][1]);
			s.insert(m[s3][0]);
			if(s.size()==3){
				cout << "Yes" << endl;
				return 0;
			}

		}
	}


	if(s1==s3){
		if(m[s1].size()==2 && m[s2].size()==1){
			set<ll> s;
			s.insert(m[s1][0]);
			s.insert(m[s1][1]);
			s.insert(m[s2][0]);
			if(s.size()==3){
				cout << "Yes" << endl;
				return 0;
			}

		}
	}


	if(s2==s3){
		if(m[s2].size()==2 && m[s1].size()==1){
			set<ll> s;
			s.insert(m[s2][0]);
			s.insert(m[s2][1]);
			s.insert(m[s1][0]);
			if(s.size()==3){
				cout << "Yes" << endl;
				return 0;
			}

		}
	}







	vector<ll> v;
	REP(i,m[s1].size()){
		REP(j,m[s2].size()){
			if(m[s1][i]==m[s2][j]) continue;

			REP(k,m[s3].size()){
				if(m[s3][k]==m[s1][i] || m[s3][k]==m[s2][j]) continue;

				v.push_back(100*m[s1][i]+10*m[s2][j]+m[s3][k]);

			}
		}
	}




	if(v.size()==1) cout << "Yes" << endl;
	else cout << "No" << endl;



	return 0;

}
0