結果
| 問題 |
No.2629 A replace B replace C
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-02-16 21:41:55 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 1,058 bytes |
| コンパイル時間 | 505 ms |
| コンパイル使用メモリ | 73,456 KB |
| 最終ジャッジ日時 | 2025-02-19 13:42:25 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 61 |
ソースコード
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
using ll=long long;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;}
template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N;
string S,T;
cin>>N>>S>>T;
int X=0,Y=0,Z=0;
for(int i=0;i<N;i++){
if(S[i]>T[i]){
cout<<"No"<<"\n";
return 0;
}
if(S[i]=='A'&&T[i]=='B')X++;
if(S[i]=='B'&&T[i]=='C')Y++;
if(S[i]=='A'&&T[i]=='C')Z++;
}
while(X>0||Y>0||Z>0){
if(Z>0){
if(Y==0){
cout<<"No"<<"\n";
return 0;
}
Z--;
}else{
if(X==0||Y==0){
cout<<"No"<<"\n";
return 0;
}
X--;
Y--;
}
}
cout<<"Yes"<<"\n";
}