Submission #5779466


Source Code Expand

Copy
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
            ∧_∧  
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     
    /   \     | |     
    /   / ̄ ̄ ̄ ̄/  |  
  __(__ニつ/     _/ .| .|____  
     \/____/ (u ⊃  
---------------------------------------------------------------------------------------------------*/














int N;
string S;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> S;
	N = S.length();
	S += "BBBBB";

	ll ans = 0;
	int R = 0;
	int BC = 0;
	rep(L, 0, N) {
		if (S[L] == 'A') {
			if (R <= L) {
				BC = 0;
				R = L + 1;
				while (R < N) {
					if (S[R] == 'A') R++;
					else if (S[R] == 'B' and S[R + 1] == 'C') {
						BC++;
						R += 2;
					}
					else break;
				}
			}

			ans += BC;
		}
		else if (S[L] == 'B' and S[L + 1] == 'C') BC--;
	}
	cout << ans << endl;
}





Submission Info

Submission Time
Task B - ABC
User hamayanhamayan
Language C++14 (GCC 5.4.1)
Score 600
Code Size 1862 Byte
Status AC
Exec Time 3 ms
Memory 720 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 3
AC × 27
Set Name Test Cases
Sample 0_000.txt, 0_001.txt, 0_002.txt
All 0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt, 1_017.txt, 1_018.txt, 1_019.txt, 1_020.txt, 1_021.txt, 1_022.txt, 1_023.txt, 1_024.txt, 1_025.txt, 1_026.txt
Case Name Status Exec Time Memory
0_000.txt AC 1 ms 256 KB
0_001.txt AC 1 ms 256 KB
0_002.txt AC 1 ms 256 KB
1_003.txt AC 1 ms 256 KB
1_004.txt AC 1 ms 256 KB
1_005.txt AC 1 ms 256 KB
1_006.txt AC 3 ms 720 KB
1_007.txt AC 3 ms 720 KB
1_008.txt AC 3 ms 720 KB
1_009.txt AC 3 ms 720 KB
1_010.txt AC 3 ms 720 KB
1_011.txt AC 2 ms 720 KB
1_012.txt AC 2 ms 720 KB
1_013.txt AC 2 ms 720 KB
1_014.txt AC 2 ms 720 KB
1_015.txt AC 2 ms 720 KB
1_016.txt AC 2 ms 720 KB
1_017.txt AC 2 ms 720 KB
1_018.txt AC 2 ms 720 KB
1_019.txt AC 2 ms 720 KB
1_020.txt AC 2 ms 720 KB
1_021.txt AC 2 ms 720 KB
1_022.txt AC 3 ms 720 KB
1_023.txt AC 3 ms 720 KB
1_024.txt AC 3 ms 720 KB
1_025.txt AC 3 ms 720 KB
1_026.txt AC 3 ms 720 KB