結果

問題 No.2021 Not A but B
ユーザー akinyanakinyan
提出日時 2022-07-29 22:03:48
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 961 bytes
コンパイル時間 2,672 ms
コンパイル使用メモリ 241,736 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-09-26 21:00:58
合計ジャッジ時間 4,742 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 6 ms
4,376 KB
testcase_28 AC 6 ms
4,380 KB
testcase_29 AC 6 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ch = char;
using ll = long long;
using ld = long double;
using db = double;
using st = string;
using vdb = vector<db>;
using vvdb = vector<vdb>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<ld>;
using vvd = vector<vd>;
using vs = vector<st>;
using vvs = vector<vs>;
using vc = vector<ch>;
using vvc = vector<vc>;
using vb = vector<bool>;
using vvb = vector<vb>;
const ll mod = 998244353;
const ll MOD = 1000000007;
using vp = vector<pair<ll,ll>>;
#define fi first
#define se second

int main(){
  ll N;
  cin>>N;
  st S;
  cin>>S;
  ll ans=1;
  ll a,b,c;
  ll f=0;
  if(S.at(0)=='A')
    c=0;
  else
    c=1;
  for(int i=1; i<N-1; i++){
    if(S.at(i)=='A')
      a=0;
    else
      a=1;
    if(S.at(i+1)=='A')
      b=0;
    else
      b=1;
    if(a==1&&b==1)
      f=1;
    if(a==0||b==0)
      ans++;
    if(b==1&&c==1)
      ans--;
    c=a;
  }
  if(f)
    ans++;
  cout<<ans<<endl;
}
0