Official
B - Cycle Hit Editorial
by
B - Cycle Hit Editorial
by
sugarrr
色々な解法が考えられますが、No
となる条件を考えるのが簡単だと思います。
No
となる条件は
- \(S_i = S_j (i \neq j)\) なる \( (i, j)\) が存在する
ことです。
この方針で実装すると、以下のようになります。
C++による実装例:
#include<bits/stdc++.h>
using namespace std;
signed main(){
vector<string>s(4);
for(int i=0;i<=3;i++)cin>>s[i];
for(int i=0;i<=3;i++){
for(int j=0;j<=3;j++){
if(i!=j && s[i]==s[j]){
cout<<"No"<<endl;
return 0;//プログラムを終了する
}
}
}
cout<<"Yes"<<endl;
return 0;
}
posted:
last update: