結果

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

ソースコード

diff #

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

#include<atcoder/math>
using namespace atcoder;

void solve(){
	vector<vector<string>> A={{"gray","brown","green","cyan","blue","yellow","orange","red"},{
	"gray","green","blue","yellow","red"},{
	"gray","green","cyan","blue","violet","orange","red"}};

	vector<string> S(3);
	cin>>S[0]>>S[1]>>S[2];
	
	ll cnt=0;
	vector<ll> P={0,1,2};
	set<vector<string>> Q;
	do{
		bool OK=1;
		if(Q.count({S[P[0]],S[P[1]],S[P[2]]}))continue;
		Q.insert({S[P[0]],S[P[1]],S[P[2]]});
		for(int i=0;i<3;i++){
			bool E=0;
			for(auto s:A[i])if(s==S[P[i]])E=1;
			if(!E)OK=0;
		}
		if(OK)cnt++;
	}while(next_permutation(P.begin(),P.end()));
	cout<<(cnt==1?"Yes":"No")<<endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);


	int T=1;
	// cin>>T;
	while(T--)solve();
	
}
0