結果
| 問題 |
No.2021 Not A but B
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-07-29 22:03:48 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 961 bytes |
| コンパイル時間 | 2,765 ms |
| コンパイル使用メモリ | 244,920 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-19 14:49:50 |
| 合計ジャッジ時間 | 3,381 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 7 WA * 19 |
ソースコード
#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;
}