結果
| 問題 | No.2629 A replace B replace C |
| コンテスト | |
| ユーザー |
kokosei
|
| 提出日時 | 2024-02-16 22:41:21 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 744 bytes |
| 記録 | |
| コンパイル時間 | 3,102 ms |
| コンパイル使用メモリ | 249,292 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-09-28 21:17:41 |
| 合計ジャッジ時間 | 5,166 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 53 WA * 8 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int N;
string S, T;
int ord[201010];
int main(void){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> N >> S >> T;
bool f = true;
for(int i = 0;i < N;i++){
f &= (S[i] <= T[i]);
ord[i] = i;
}
sort(ord, ord + N, [](int a, int b){
if(S[a] != S[b])return S[a] < S[b];
return T[a] < T[b];
});
for(int i = 0, a = 0;i < N;i++){
if(S[ord[i]] == T[ord[i]])continue;
if(T[ord[i]] == 'C'){
if(a-- == 0)f = false;
}
if(S[ord[i]] == 'A'){
a++;
}
if(i == N - 1 && a != 0)f = false;
}
cout << (f ? "Yes\n" : "No\n");
return 0;
}
kokosei