Submission #50422613
Source Code Expand
#ifdef LOGX
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
/*---------macro---------*/
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define unless(x) if(!(x))
#define until(x) while(!(x))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define mybit(i,j) (((i)>>(j))&1)
/*---------type/const---------*/
constexpr int big=1000000007;
//constexpr int big=998244353;
constexpr double EPS=1e-8; //適宜変える
typedef long long ll;
typedef unsigned long long ull;
typedef std::string::const_iterator state; //構文解析
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
constexpr char newl='\n';
struct{
constexpr operator int(){return -int(1e9)-10;}
constexpr operator ll(){return -ll(1e18)-10;}
}neginf;
struct{
constexpr operator int(){return int(1e9)+10;}
constexpr operator ll(){return ll(1e18)+10;}
constexpr auto operator -(){return neginf;}
}inf;
/*---------debug---------*/
#ifdef LOGX
#include <template/debug.hpp>
#else
#define dbg(...) ;
#define dbgnewl ;
#define prt(x) ;
#define _prt(x) ;
#endif
/*---------function---------*/
template<typename T> T max(const std::vector<T> &a){T ans=a[0];for(T elem:a){ans=max(ans,elem);}return ans;}
template<typename T> T min(const std::vector<T> &a){T ans=a[0];for(T elem:a){ans=min(ans,elem);}return ans;}
template<typename T,typename U> bool chmin(T &a,const U b){if(a>b){a=b;return true;}return false;}
template<typename T,typename U> bool chmax(T &a,const U b){if(a<b){a=b;return true;}return false;}
bool valid(int i,int j,int h,int w){return (i>=0 && j>=0 && i<h && j<w);}
template<class T,class U>T expm(T x,U y,const ll mod=big){T res=1;while(y){if(y&1)(res*=x)%=mod;(x*=x)%=mod;y>>=1;}return res;}
template<class T,class U>T exp(T x,U y){T res=1;while(y){if(y&1)res*=x;x*=x;y>>=1;}return res;}
int abc(int a,int b){
if(a>b)return 1;
if(a==b)return 0;
return -1;
}
int main(){
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cout << std::fixed << std::setprecision(10);
/*------------------------------------*/
int n;
cin >> n;
string c;
cin >> c;
vector<int> d(n);
//0番以外の累積和
rep2(i,1,n)d[i]=d[i-1] + int(c[i] == 'A');
int cnt=1;
rep2(i,1,n){
int v = d[i-1] + int(c[0] == 'A');
int w = d[i];
dbg(i,v,w);
if(abc(2 * v, i) != abc(2 * w, i))cnt++;
}
cout << cnt << endl;
}
Submission Info
| Submission Time |
|
| Task |
C - Election |
| User |
logx |
| Language |
C++ 20 (gcc 12.2) |
| Score |
600 |
| Code Size |
2654 Byte |
| Status |
AC |
| Exec Time |
9 ms |
| Memory |
8148 KiB |
Compile Error
Main.cpp:36:2: warning: ‘inf’ defined but not used [-Wunused-variable]
36 | }inf;
| ^~~
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
600 / 600 |
| Status |
|
|
| Set Name |
Test Cases |
| Sample |
sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt |
| All |
in01.txt, in02.txt, in03.txt, in04.txt, in05.txt, in06.txt, in07.txt, in08.txt, in09.txt, in10.txt, in11.txt, in12.txt, in13.txt, in14.txt, in15.txt, in16.txt, in17.txt, in18.txt, in19.txt, in20.txt, in21.txt, in22.txt, in23.txt, in24.txt, in25.txt, in26.txt, sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt |
| Case Name |
Status |
Exec Time |
Memory |
| in01.txt |
AC |
1 ms |
3484 KiB |
| in02.txt |
AC |
1 ms |
3492 KiB |
| in03.txt |
AC |
1 ms |
3360 KiB |
| in04.txt |
AC |
1 ms |
3420 KiB |
| in05.txt |
AC |
6 ms |
8012 KiB |
| in06.txt |
AC |
6 ms |
8092 KiB |
| in07.txt |
AC |
5 ms |
8012 KiB |
| in08.txt |
AC |
5 ms |
7992 KiB |
| in09.txt |
AC |
5 ms |
7988 KiB |
| in10.txt |
AC |
1 ms |
3368 KiB |
| in11.txt |
AC |
1 ms |
3360 KiB |
| in12.txt |
AC |
1 ms |
3492 KiB |
| in13.txt |
AC |
1 ms |
3516 KiB |
| in14.txt |
AC |
9 ms |
8056 KiB |
| in15.txt |
AC |
5 ms |
8096 KiB |
| in16.txt |
AC |
6 ms |
8084 KiB |
| in17.txt |
AC |
6 ms |
8092 KiB |
| in18.txt |
AC |
6 ms |
8060 KiB |
| in19.txt |
AC |
6 ms |
8104 KiB |
| in20.txt |
AC |
6 ms |
8148 KiB |
| in21.txt |
AC |
6 ms |
8128 KiB |
| in22.txt |
AC |
6 ms |
8096 KiB |
| in23.txt |
AC |
1 ms |
3388 KiB |
| in24.txt |
AC |
1 ms |
3492 KiB |
| in25.txt |
AC |
1 ms |
3484 KiB |
| in26.txt |
AC |
1 ms |
3552 KiB |
| sample-01.txt |
AC |
1 ms |
3480 KiB |
| sample-02.txt |
AC |
1 ms |
3468 KiB |
| sample-03.txt |
AC |
1 ms |
3544 KiB |
| sample-04.txt |
AC |
1 ms |
3552 KiB |