結果
| 問題 | No.2629 A replace B replace C | 
| コンテスト | |
| ユーザー |  chro_96 | 
| 提出日時 | 2024-02-16 23:38:32 | 
| 言語 | C (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 4 ms / 2,000 ms | 
| コード長 | 667 bytes | 
| コンパイル時間 | 336 ms | 
| コンパイル使用メモリ | 29,312 KB | 
| 実行使用メモリ | 6,824 KB | 
| 最終ジャッジ日時 | 2024-09-28 22:41:36 | 
| 合計ジャッジ時間 | 1,920 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 5 | 
| other | AC * 61 | 
ソースコード
#include <stdio.h>
int main () {
  int n = 0;
  char s[200001] = "";
  char t[200001] = "";
  
  int res = 0;
  
  int is_ng = 0;
  int cnt[3] = {};
  
  res = scanf("%d", &n);
  res = scanf("%s", s);
  res = scanf("%s", t);
  
  for (int i = 0; i < n; i++) {
    if (s[i] > t[i]) {
      is_ng = 1;
    } else if (s[i] == 'A' && t[i] == 'B') {
      cnt[0]++;
    } else if (s[i] == 'B' && t[i] == 'C') {
      cnt[1]++;
    } else if (s[i] == 'A' && t[i] == 'C') {
      cnt[2]++;
    }
  }
  
  if (cnt[0] != cnt[1] || (cnt[2] > 0 && cnt[0] == 0)) {
    is_ng = 1;
  }
  
  if (is_ng > 0) {
    printf("No\n");
  } else {
    printf("Yes\n");
  }
  
  return 0;
}
            
            
            
        