結果
問題 |
No.2629 A replace B replace C
|
ユーザー |
![]() |
提出日時 | 2024-02-16 22:44:09 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 726 bytes |
コンパイル時間 | 2,859 ms |
コンパイル使用メモリ | 248,288 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-09-28 21:20:48 |
合計ジャッジ時間 | 5,055 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 WA * 1 |
other | AC * 44 WA * 17 |
ソースコード
#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'){ a--; } if(S[ord[i]] == 'A'){ a++; } if(i == N - 1 && a != 0)f = false; } cout << (f ? "Yes\n" : "No\n"); return 0; }