結果
問題 | No.2629 A replace B replace C |
ユーザー |
![]() |
提出日時 | 2024-02-11 16:15:00 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 9 ms / 2,000 ms |
コード長 | 764 bytes |
コンパイル時間 | 2,653 ms |
コンパイル使用メモリ | 244,644 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-09-28 18:16:59 |
合計ジャッジ時間 | 4,504 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 61 |
ソースコード
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; string s, t; cin >> s >> t; int p = 0, q = 0, r = 0; for (int i = 0; i < n; i++){ int x = s[i] - 'A'; int y = t[i] - 'A'; if (x > y){ cout << "No" << endl; return 0; } if (x == y) continue; if (x == 0 && y == 1){ p++; } else if (x == 0 && y == 2){ q++; } else if (x == 1 && y == 2){ r++; } else { abort(); } } if (p != r){ cout << "No" << endl; return 0; } if (q >= 1 && r == 0){ cout << "No" << endl; } else { cout << "Yes" << endl; } }