結果
問題 |
No.2629 A replace B replace C
|
ユーザー |
![]() |
提出日時 | 2024-02-16 22:40:19 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 700 bytes |
コンパイル時間 | 3,213 ms |
コンパイル使用メモリ | 248,892 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-09-28 21:16:05 |
合計ジャッジ時間 | 4,971 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 46 WA * 15 |
ソースコード
#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){ return S[a] < S[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; }