QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#784686#4950. Finding Maximal Non-Trivial MonotonesWeaRD276#AC ✓1ms3960kbC++201.2kb2024-11-26 15:42:572024-11-26 15:42:58

Judging History

你现在查看的是最新测评结果

  • [2024-11-26 15:42:58]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3960kb
  • [2024-11-26 15:42:57]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define x first
#define y second
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)

typedef long long ll;
typedef double db;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<db, db> pdd;
typedef pair<ll, ll> pll;


int solve()
{
	int n;
	string s;
	if (!(cin >> n >> s))
		return 1;
	
	int ans = 0;
	vector<string> as;
	string curr = "";
	FOR (i, 0, n)
	{
		if (s[i] == 'a')
			curr += s[i];
		else
		{
			if (sz(curr) > 1)
				ans += sz(curr);
			curr = "";
		}
	}
	if (sz(curr) > 1)
		ans += sz(curr);
	cout << ans << '\n';
	
	
	return 0;
}

int32_t main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int TET = 1e9;
	//cin >> TET;
	for (int i = 1; i <= TET; i++)
	{
		if (solve())
		{
			break;
		}
		#ifdef ONPC
			cerr << "_____________________________\n";
		#endif
	}
	#ifdef ONPC
		cerr << "\nfinished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec\n";
	#endif
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3544kb

input:

7
abababa

output:

0

result:

ok 1 number(s): "0"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3544kb

input:

7
bababab

output:

0

result:

ok 1 number(s): "0"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3536kb

input:

10
aababaaabb

output:

5

result:

ok 1 number(s): "5"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

10
bbaababaaa

output:

5

result:

ok 1 number(s): "5"

Test #5:

score: 0
Accepted
time: 0ms
memory: 3800kb

input:

2
bb

output:

0

result:

ok 1 number(s): "0"

Test #6:

score: 0
Accepted
time: 0ms
memory: 3552kb

input:

2
ba

output:

0

result:

ok 1 number(s): "0"

Test #7:

score: 0
Accepted
time: 0ms
memory: 3576kb

input:

2
aa

output:

2

result:

ok 1 number(s): "2"

Test #8:

score: 0
Accepted
time: 0ms
memory: 3832kb

input:

2
bb

output:

0

result:

ok 1 number(s): "0"

Test #9:

score: 0
Accepted
time: 0ms
memory: 3832kb

input:

2
ab

output:

0

result:

ok 1 number(s): "0"

Test #10:

score: 0
Accepted
time: 0ms
memory: 3604kb

input:

2
ab

output:

0

result:

ok 1 number(s): "0"

Test #11:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

2
ab

output:

0

result:

ok 1 number(s): "0"

Test #12:

score: 0
Accepted
time: 0ms
memory: 3760kb

input:

2
aa

output:

2

result:

ok 1 number(s): "2"

Test #13:

score: 0
Accepted
time: 0ms
memory: 3832kb

input:

2
aa

output:

2

result:

ok 1 number(s): "2"

Test #14:

score: 0
Accepted
time: 0ms
memory: 3568kb

input:

2
ba

output:

0

result:

ok 1 number(s): "0"

Test #15:

score: 0
Accepted
time: 0ms
memory: 3644kb

input:

100
bbbabbbaababaaabaaaaabaaaaaabbabbababbbaabaababbbbaaaaaaabbabaaabbbaaabbbaaabbbababbbbaabbbbbaaabbbb

output:

41

result:

ok 1 number(s): "41"

Test #16:

score: 0
Accepted
time: 0ms
memory: 3488kb

input:

100
aabbababbbbbabaabbababaaaaabbbbbbbaaaabbbabbbbbababbababbbbabbbbbbbbbaaaabbbabaaaaabaaabababbabababb

output:

25

result:

ok 1 number(s): "25"

Test #17:

score: 0
Accepted
time: 0ms
memory: 3600kb

input:

100
bababbaaaaabbbababbaabababbaaababaabbabaaaaabaabbbbaababaaababaaaababbabbaaabaaabaababaabbbbbaabaabb

output:

42

result:

ok 1 number(s): "42"

Test #18:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

100
abbabababbbbbaabaaaabbbbbbbabbabababbaaababababaaaababaabaabbabaabaaabababbbbabbbbaabbbaababbaabbaba

output:

28

result:

ok 1 number(s): "28"

Test #19:

score: 0
Accepted
time: 0ms
memory: 3828kb

input:

100
babbbabaaabbbaabbaaaaababababbaabababbabaaaaabbbbaaababaaaaabbbaaaaabbbabaabbabaaaabaaabaaaaaaaaaabb

output:

49

result:

ok 1 number(s): "49"

Test #20:

score: 0
Accepted
time: 0ms
memory: 3548kb

input:

1000
aaabbaabaababbbbbbaabaaababaabbaabaabbabbbbbaabbbbaaabaabababaaaabaaaabbbbbbbbbbababbaaaaababbabbbbaaabaaababaaabbaababbbaabbbbbbbbbaabbaabaaabaabbbabbbaababbbaaabaabbbbaabbbbaabbbbaabaababbbabaaaabaaaabbaaaabaaabbbbaaabbbaababbbabaabbbababbabaabbabbaabbbbbabbabaabababbaaababaaabbbaabaaabbbaaab...

output:

378

result:

ok 1 number(s): "378"

Test #21:

score: 0
Accepted
time: 0ms
memory: 3800kb

input:

1000
aabaabaaabbbbabbabaaaaabaabababaabbaabbaabaaaaaaabbabbabbbabaaabaaababaaabaabbbbabbbabaabbbaaaaabaaaabbabaababaabbbababbabbbabaababaaabaababbbaabbbaabbababbaabbbaabbaabbbaabbbbabbaabaababaabbbbaabbaabbbaabbababbaabbbbababbabaaabaababbbbbaaaaababaaaaaabbbbbbaaabbabbbbaaaaabbaabbaaaaaabbbbbbabbba...

output:

431

result:

ok 1 number(s): "431"

Test #22:

score: 0
Accepted
time: 0ms
memory: 3604kb

input:

1000
abbbabbbbaaabbaaabababbbaaabbbbaaaaabbbbabaabbbbbbbbbbabaababbabbabbbbaaabbabbaaababbbbbabaababaabaaaababbaabaaababbbabbbaabbaabaaaabbbbaabaaababaabbabaaabbbaaaaabbabbbbbaaaaabbbabbaaaabbaaaaaabaabbaaababbaaabaabbabbaaabbbaaabababaaaabbaabaaaaaababaaabaabbabbababaaabaabbabaabbabbbabaabaaabababa...

output:

410

result:

ok 1 number(s): "410"

Test #23:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

1000
aabbbaaaaaaababaabababababbbbbbabbbabbbaaabbbbbabababbabbbbababbbbabbbbbaaaaaabbbaaabbabbbbaababbaabbabaaaabaaaaabbbabbaabbababababbbaaaabababbaabbabbbaaaaabaaabbaabababbbabbabbbbbbbbaaabbaaaabbaaaabbbaabbbabbababbaaabaaaaababababaaaababbbbababbaaababbabbaaaaaaaabbbaabbbaaabaabaaabbaaabbbaaaaab...

output:

363

result:

ok 1 number(s): "363"

Test #24:

score: 0
Accepted
time: 0ms
memory: 3824kb

input:

1000
bbbbabbaababaaaabbbbababbabbbabbaabaababbaabbabaabbbbbbaaababaaaaabbbaabbaaaababaabbbababaaaaabaaaaabaabbabababbaabbaababbaaaabbbaabbbaaaaaabaabbbaabaaabbabbabbabaabbaaaabaababaababbbaaaabaaabbbaaabbbabbbbaaaabaaaababaabbbbbbaabbbbaabbaaabbbbabaaabbabaabbbabbabbabbbbaabbbbbaababaaaabbbabbbababb...

output:

408

result:

ok 1 number(s): "408"

Test #25:

score: 0
Accepted
time: 0ms
memory: 3600kb

input:

1000
bbbbbabbbbaaaaaaaaaabbbbababaabaabbaaaaababaaabababbabaaabbbbaabbbabbbbaabbababbbbaabbbaabbabbbbbbbabababbabbaaababbbbabaababbbbbabbaabaaabbaaabbabbbbbaababbabbabaabbaababaaababbbabbabbaabbbbabbbbabbbbbababaaaaaaaaaabbbaabbababbbaabbaaabaaaaabbbbbabbbaaababbbabbbababbaabbbababbbbbaaababbabbabbb...

output:

360

result:

ok 1 number(s): "360"

Test #26:

score: 0
Accepted
time: 0ms
memory: 3600kb

input:

1000
abbbbababbbaababbabbbbbabaabbaaaabaaaabbbabbbabbababbaabbaaaababaabaaabbababbababbbbabbaaaabbabaababbbbbaabaabbbabbbbbaabaaababbaaababaabbbabababbabbaaababbbabbaaaaabbaaabbbbabbbaababaabbbbbbaaabaababbbbaababaaaabaabbabbbaabaaaabababaaaababbaaaaabababbabaaabbbabbbabbbaaababbaabbbabbbbbbbabbbbab...

output:

347

result:

ok 1 number(s): "347"

Test #27:

score: 0
Accepted
time: 0ms
memory: 3604kb

input:

1000
aaaaabaaaabababbbabbababababababaaaabaaabaabbbabbbaabbbbabababaaaababaabaaaaabbbaaaabbbbababbabbbaabaabbaaaababbbbbbbaaaaabbabaabaaaabbabbabaaabbbbabaababaabaaaaabbabbbaaababbabaababbabbababbbbaababaabbbbbbaabbababaaabbabaaaaabbbaaaaaaababbbbabbbabbaaaababbbabbbabbabbbabbbbbabbabbaaabbbababbaba...

output:

364

result:

ok 1 number(s): "364"

Test #28:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

1000
bbbbbaaaabbbbaabaaaaaaaaababbabbbabababbaabaabbababaabbabaaaabababaaabbbbababaabbbaabaaabaaaaabaabababbabbabaabbbabbaaaaaabbbbaababbaaaabababaabbaabbbabbaaaaaababaabbabaaaaaaabaaabaababaabbbabaabaabbbabbaaaabaaaababaababbabbaabbaabbaababaaabbbbbabbabababbbabbbaabbabbaabababaababbabbaaabbbaabaaa...

output:

366

result:

ok 1 number(s): "366"

Test #29:

score: 0
Accepted
time: 0ms
memory: 3576kb

input:

1000
aaaabaaaabaaabbabbbbaabaabaaabaabbabbaaaaaabbbbaaabbbbbabababbaaabbbbbbbbaaabaaaababbababbabbbabbabaabbaaaaabbbbbbbaabaababbbaabbaaaaaabbbbabbaaabbbbaaabaabbbbaaaaaaabbababbaaaabaaaabbbabbaaabbaaabbaabbaabbbbaabbabbbaaaabaaabbbbbaabbbbaaaabababbbabaabbbabbbaaabbbabbbbaabbbabbbabaaaabbabaaaabbbb...

output:

375

result:

ok 1 number(s): "375"

Test #30:

score: 0
Accepted
time: 0ms
memory: 3624kb

input:

10000
babababaaababbabbbbbabbaababaabaababbbabbaaaabaaababababbabbbababbaaaabbabbaabaabaababaabbabbaaabaaabaaaaabbbababaaabbbbaaabbaaaabaabbaaaaaabbbabbabbabababababaabbabbbbbbaaaaaaaaaaaabbbbbbaaaabbaaaaaaaaaaaabaabaabaaabbbbbaabaabbabaabaaabbabbabaabaabbababbabbaaaaabbabbabaaabbabaaaaaaabaaabbabab...

output:

3630

result:

ok 1 number(s): "3630"

Test #31:

score: 0
Accepted
time: 0ms
memory: 3856kb

input:

10000
baabababbaabbaaabbaabbabaabaaaababaabaabbbabbabababaabaaabaababbbabbaaaaabbabaabaaaabbaaaaabaabbabaabbabbbaababbabbbbaaabababbbbbabaaabbabbaaaabbaaababbbbabbbbaaabbabbbababaabbbabbbbaaabbaabaababbabaaabbabbbaaababbababbbabaabbabbbaaabaaaabaaabbbbabbabababbbaaabbbaaaabbbbabbbaabaabaabaabbabbaba...

output:

3880

result:

ok 1 number(s): "3880"

Test #32:

score: 0
Accepted
time: 0ms
memory: 3564kb

input:

10000
aaabbaabaaabbaaaaaabbaaabaabbbaaababbbaaabaabaababaababaabbbaabbabbbbbbabaabbaabaabbbbaaaabbbbbabbbbabbaabaaababbbbbabbaabbabbbbaaaaaaaaababbbbababaababbabbabbabbbababaabbbabbaabbbababaaaabaabbaababbbbbabaabbbbaaaaaababbbaaabbabaabaabbaabbabaaabaaaaaabbbaabbbbabaabbbaaaabbbbbbbaabbbabaaaabaaab...

output:

3736

result:

ok 1 number(s): "3736"

Test #33:

score: 0
Accepted
time: 0ms
memory: 3848kb

input:

10000
aaababaaababbababaaabbbbbbbabababaaaabbbbbbaabbbababbaaabbaabbbbaaabababbbbababbbbbbbabbbbabbbabbbabbabbaababbabaabbabbbaababaaaaaabbbbbabaabaaababaaaabbbbabaababbaaabbbababbbbaaabaaabbaaaaaaababbaabababbbbbaabbbaabaabbabaaabaababbabbababababaaabbbbbaaaaabbaababbaabbbbaabaaaaabbbabaabbabbbabbb...

output:

3740

result:

ok 1 number(s): "3740"

Test #34:

score: 0
Accepted
time: 0ms
memory: 3600kb

input:

10000
aaabbbabbaabbbbbaabbabbabbbbbbabaababbaaaabbaaaaaaaabababaaabbaabbaabbababaaaababbabbbaaabaabbbbbbabbababbaabbabababbaabaabaabaaabbbabaaaabbaabbbabbaaababbbbbabaabbbbbbbbbbabbbaabbbaaaabaaabbaabbaaaabbbaaabaaaaaaaaabbabbaabbabbabaaaaababababbabbabbbbbabababaabbaaabbaabbbaaabaaababbaaabaabbabab...

output:

3779

result:

ok 1 number(s): "3779"

Test #35:

score: 0
Accepted
time: 1ms
memory: 3888kb

input:

100000
ababaababaabbabaabaaababbbabaaababaaaaaababaaabaabbaaabaababaaababaabaabbbaaabbabbbbbbaaaabbbabaaaabbbaabbaaabbabaaaabaabbabbbabbbabaabaababababbaababaabbbaaabbbabababbabaaaaabbbbababbbbaabababbbabababaaabbbbaabbbabaaaaabaababbbbbabbbbbabbbbbaababbbbababababbabaabbaabbababbaabaaabaaaaabbbbbbb...

output:

37404

result:

ok 1 number(s): "37404"

Test #36:

score: 0
Accepted
time: 1ms
memory: 3724kb

input:

100000
bbaabbabbaabaaabbbbabbaaaabbbabbbababbababbaaabbababababbabbaaabbbabbbababaaaabbbbbbbbaaaaaaabaabaaaaaabaaabaababbaaaabababababbabbabaaababbaabbaaaabaabaabbbbaabbaabbaaaabaaabbbbabbabbabbaabbbbbbbbbababababbbaaabaaabbbbaaababbabbaaaabaaabbabbaaabaaababaaabbbaabababababbabbabbbbaaabbaaaaaaaaaa...

output:

37359

result:

ok 1 number(s): "37359"

Test #37:

score: 0
Accepted
time: 1ms
memory: 3724kb

input:

100000
aaaabbaaaaabbbaabbabbbbababbabbaababbababbbbbbbaabbbbabbaababbbaaaaabbbabbbaabaaaaababbbbaaaabbbabaababababbbaaaabaabbbabbaabaabababbbbbbbbbbbabbaaabbabbaabbbbabaaabbabbabbaabbabaaaaaabbbbbaabbaabaaaaabaababaababababbbababbbaabaaaabbbbbbbabbbabbaabbbbaababbaabbabbbabbbbbabbaabbabbabbbbaababab...

output:

37291

result:

ok 1 number(s): "37291"

Test #38:

score: 0
Accepted
time: 1ms
memory: 3672kb

input:

100000
ababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababa...

output:

0

result:

ok 1 number(s): "0"

Test #39:

score: 0
Accepted
time: 1ms
memory: 3660kb

input:

100000
ababababababababababbbababababababababababababababababababababababababababbbababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababa...

output:

712

result:

ok 1 number(s): "712"

Test #40:

score: 0
Accepted
time: 1ms
memory: 3668kb

input:

100000
abbbababbbababaaabaabbabbbabababababaaabababababababaaabaaabaaaaababababbbaaabababaaababababababababbbaaababbabbabababababababababbaabaabaaaababaabaaaabbabbbbababaaaaabbbaaabbbabbaababaaabaaaaabbbabababababaaabaaababababababababbbbbabaabbabbbabaaabbbabaaaaabbbabababaaabababaaababababababbbbbb...

output:

24034

result:

ok 1 number(s): "24034"

Test #41:

score: 0
Accepted
time: 0ms
memory: 3664kb

input:

100000
abaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaab...

output:

66666

result:

ok 1 number(s): "66666"

Test #42:

score: 0
Accepted
time: 0ms
memory: 3764kb

input:

100000
abaabaababbaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaababbaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaababbaabaabaabaabaabaabaabaabaab...

output:

66201

result:

ok 1 number(s): "66201"

Test #43:

score: 0
Accepted
time: 1ms
memory: 3608kb

input:

100000
bbaaababbaaaabaabaabbbbaaaaabaaaaabbabbbbaabaababbbabbbbabbbabbaaaabaabaabaabaababbaabaabaaaaaaabbaabbaaaabaabaabaabaabaaababaababbabbaabaababbaabbabaababbbbbbabaaabbbabbaababbabbaababbaabaababbabbaaaabbbabaabaababababbbbabbaabaabbabaabbbbaaaaaaaabaabaabaabaabaabaabbbbabbaabbabaabaaaaaaaaaaaa...

output:

51478

result:

ok 1 number(s): "51478"

Test #44:

score: 0
Accepted
time: 1ms
memory: 3884kb

input:

100000
babbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabba...

output:

0

result:

ok 1 number(s): "0"

Test #45:

score: 0
Accepted
time: 1ms
memory: 3960kb

input:

100000
babbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbaababbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbbbbabbabbabbabbabbabbabbabbabba...

output:

668

result:

ok 1 number(s): "668"

Test #46:

score: 0
Accepted
time: 1ms
memory: 3924kb

input:

100000
babbabbabaaababaabbababbbaababbabbabbabbaababbbbbabbaababbaababaabbabbaababbababbbabbbababbbbbabaabbbababbbbbabbaababbaaaabbbbbabbababbbabbaabbbbabbababbbabbbababbabbabaabababaababbabbabaabbabbbababbabbabbabaabbbababbbbaabbabbbbbabbabbabaabbabbabbabbabbabbabbaababbaababbabbbababbbababaaababbb...

output:

20467

result:

ok 1 number(s): "20467"