結果
| 問題 |
No.2021 Not A but B
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-07-30 00:35:42 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 38 ms / 2,000 ms |
| コード長 | 398 bytes |
| コンパイル時間 | 2,096 ms |
| コンパイル使用メモリ | 197,520 KB |
| 最終ジャッジ日時 | 2025-01-30 16:24:34 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 26 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N;
cin>>N;
string S;
cin>>S;
set<int>p;
int u=0,ans=0;
for(int i=0;i<N-1;i++){
if(S[i]=='B'&&S[i+1]=='B')u=1;
else{
if(S[i]=='B')p.insert(i+1);
if(S[i+1]=='B')p.insert(i);
if(S[i]=='A'&&S[i+1]=='A')++ans;
}
}
cout<<ans+p.size()+u<<'\n';
}