結果

問題 No.2240 WAC
ユーザー chro_96
提出日時 2023-03-10 21:34:54
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 727 bytes
コンパイル時間 159 ms
コンパイル使用メモリ 29,952 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-18 03:48:05
合計ジャッジ時間 1,481 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int main () {
  int n = 0;
  int m = 0;
  char s[400001] = {};
  
  int res = 0;
  
  int is_ok = 1;
  
  int acnt = 0;
  int ccnt = 0;
  int wcnt = 0;
  
  res = scanf("%d", &n);
  res = scanf("%d", &m);
  res = scanf("%s", s);
  
  for (int i = 0; i < 2*(n+m); i++) {
    if (s[i] == 'A') {
      acnt++;
    } else if (s[i] == 'C') {
      ccnt++;
      if (acnt < ccnt) {
        is_ok = 0;
      }
    }
  }
  
  acnt = 0;
  for (int i = 2*(n+m)-1; i >= 0; i--) {
    if (s[i] == 'A') {
      acnt++;
    } else if (s[i] == 'W') {
      wcnt++;
      if (acnt < wcnt) {
        is_ok = 0;
      }
    }
  }
  
  if (is_ok > 0) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  
  return 0;
}
0