QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#784703#4950. Finding Maximal Non-Trivial MonotonesLaVuna47#AC ✓1ms3948kbC++201.7kb2024-11-26 15:45:202024-11-26 15:45:35

Judging History

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

  • [2024-11-26 15:45:35]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3948kb
  • [2024-11-26 15:45:20]
  • 提交

answer

/** gnu specific **/
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
/** contains everything I need in std **/
#include <bits/stdc++.h>

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(S) ((int)S.size())
#define FOR(i, st_, n) for(int i = st_; i < n; ++i)
#define RFOR(i, n, end_) for(int i = (n)-1; i >= end_; --i)
#define x first
#define y second
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef unsigned long long ull;
typedef long double LD;
typedef pair<ull, ull> pull;
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
using namespace std;
#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif


int solve()
{
	int n;
	if(!(cin >> n))
		return 1;
	string s;
	cin >> s;
	s.pb('b');
	int res = 0;
	int ctr = 0;
	FOR(i,0,n+1)
	{
		if(s[i] != 'a')
		{
			if(ctr > 1)
				res += ctr;
			ctr = 0;
		}
		else
		{
			++ctr;
		}
	}
	cout << res << '\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
        cout << "__________________________" << endl;
#endif
    }
#ifdef ONPC
    cerr << endl << "finished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec" << endl;
#endif
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

7
abababa

output:

0

result:

ok 1 number(s): "0"

Test #2:

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

input:

7
bababab

output:

0

result:

ok 1 number(s): "0"

Test #3:

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

input:

10
aababaaabb

output:

5

result:

ok 1 number(s): "5"

Test #4:

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

input:

10
bbaababaaa

output:

5

result:

ok 1 number(s): "5"

Test #5:

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

input:

2
bb

output:

0

result:

ok 1 number(s): "0"

Test #6:

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

input:

2
ba

output:

0

result:

ok 1 number(s): "0"

Test #7:

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

input:

2
aa

output:

2

result:

ok 1 number(s): "2"

Test #8:

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

input:

2
bb

output:

0

result:

ok 1 number(s): "0"

Test #9:

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

input:

2
ab

output:

0

result:

ok 1 number(s): "0"

Test #10:

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

input:

2
ab

output:

0

result:

ok 1 number(s): "0"

Test #11:

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

input:

2
ab

output:

0

result:

ok 1 number(s): "0"

Test #12:

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

input:

2
aa

output:

2

result:

ok 1 number(s): "2"

Test #13:

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

input:

2
aa

output:

2

result:

ok 1 number(s): "2"

Test #14:

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

input:

2
ba

output:

0

result:

ok 1 number(s): "0"

Test #15:

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

input:

100
bbbabbbaababaaabaaaaabaaaaaabbabbababbbaabaababbbbaaaaaaabbabaaabbbaaabbbaaabbbababbbbaabbbbbaaabbbb

output:

41

result:

ok 1 number(s): "41"

Test #16:

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

input:

100
aabbababbbbbabaabbababaaaaabbbbbbbaaaabbbabbbbbababbababbbbabbbbbbbbbaaaabbbabaaaaabaaabababbabababb

output:

25

result:

ok 1 number(s): "25"

Test #17:

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

input:

100
bababbaaaaabbbababbaabababbaaababaabbabaaaaabaabbbbaababaaababaaaababbabbaaabaaabaababaabbbbbaabaabb

output:

42

result:

ok 1 number(s): "42"

Test #18:

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

input:

100
abbabababbbbbaabaaaabbbbbbbabbabababbaaababababaaaababaabaabbabaabaaabababbbbabbbbaabbbaababbaabbaba

output:

28

result:

ok 1 number(s): "28"

Test #19:

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

input:

100
babbbabaaabbbaabbaaaaababababbaabababbabaaaaabbbbaaababaaaaabbbaaaaabbbabaabbabaaaabaaabaaaaaaaaaabb

output:

49

result:

ok 1 number(s): "49"

Test #20:

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

input:

1000
aaabbaabaababbbbbbaabaaababaabbaabaabbabbbbbaabbbbaaabaabababaaaabaaaabbbbbbbbbbababbaaaaababbabbbbaaabaaababaaabbaababbbaabbbbbbbbbaabbaabaaabaabbbabbbaababbbaaabaabbbbaabbbbaabbbbaabaababbbabaaaabaaaabbaaaabaaabbbbaaabbbaababbbabaabbbababbabaabbabbaabbbbbabbabaabababbaaababaaabbbaabaaabbbaaab...

output:

378

result:

ok 1 number(s): "378"

Test #21:

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

input:

1000
aabaabaaabbbbabbabaaaaabaabababaabbaabbaabaaaaaaabbabbabbbabaaabaaababaaabaabbbbabbbabaabbbaaaaabaaaabbabaababaabbbababbabbbabaababaaabaababbbaabbbaabbababbaabbbaabbaabbbaabbbbabbaabaababaabbbbaabbaabbbaabbababbaabbbbababbabaaabaababbbbbaaaaababaaaaaabbbbbbaaabbabbbbaaaaabbaabbaaaaaabbbbbbabbba...

output:

431

result:

ok 1 number(s): "431"

Test #22:

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

input:

1000
abbbabbbbaaabbaaabababbbaaabbbbaaaaabbbbabaabbbbbbbbbbabaababbabbabbbbaaabbabbaaababbbbbabaababaabaaaababbaabaaababbbabbbaabbaabaaaabbbbaabaaababaabbabaaabbbaaaaabbabbbbbaaaaabbbabbaaaabbaaaaaabaabbaaababbaaabaabbabbaaabbbaaabababaaaabbaabaaaaaababaaabaabbabbababaaabaabbabaabbabbbabaabaaabababa...

output:

410

result:

ok 1 number(s): "410"

Test #23:

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

input:

1000
aabbbaaaaaaababaabababababbbbbbabbbabbbaaabbbbbabababbabbbbababbbbabbbbbaaaaaabbbaaabbabbbbaababbaabbabaaaabaaaaabbbabbaabbababababbbaaaabababbaabbabbbaaaaabaaabbaabababbbabbabbbbbbbbaaabbaaaabbaaaabbbaabbbabbababbaaabaaaaababababaaaababbbbababbaaababbabbaaaaaaaabbbaabbbaaabaabaaabbaaabbbaaaaab...

output:

363

result:

ok 1 number(s): "363"

Test #24:

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

input:

1000
bbbbabbaababaaaabbbbababbabbbabbaabaababbaabbabaabbbbbbaaababaaaaabbbaabbaaaababaabbbababaaaaabaaaaabaabbabababbaabbaababbaaaabbbaabbbaaaaaabaabbbaabaaabbabbabbabaabbaaaabaababaababbbaaaabaaabbbaaabbbabbbbaaaabaaaababaabbbbbbaabbbbaabbaaabbbbabaaabbabaabbbabbabbabbbbaabbbbbaababaaaabbbabbbababb...

output:

408

result:

ok 1 number(s): "408"

Test #25:

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

input:

1000
bbbbbabbbbaaaaaaaaaabbbbababaabaabbaaaaababaaabababbabaaabbbbaabbbabbbbaabbababbbbaabbbaabbabbbbbbbabababbabbaaababbbbabaababbbbbabbaabaaabbaaabbabbbbbaababbabbabaabbaababaaababbbabbabbaabbbbabbbbabbbbbababaaaaaaaaaabbbaabbababbbaabbaaabaaaaabbbbbabbbaaababbbabbbababbaabbbababbbbbaaababbabbabbb...

output:

360

result:

ok 1 number(s): "360"

Test #26:

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

input:

1000
abbbbababbbaababbabbbbbabaabbaaaabaaaabbbabbbabbababbaabbaaaababaabaaabbababbababbbbabbaaaabbabaababbbbbaabaabbbabbbbbaabaaababbaaababaabbbabababbabbaaababbbabbaaaaabbaaabbbbabbbaababaabbbbbbaaabaababbbbaababaaaabaabbabbbaabaaaabababaaaababbaaaaabababbabaaabbbabbbabbbaaababbaabbbabbbbbbbabbbbab...

output:

347

result:

ok 1 number(s): "347"

Test #27:

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

input:

1000
aaaaabaaaabababbbabbababababababaaaabaaabaabbbabbbaabbbbabababaaaababaabaaaaabbbaaaabbbbababbabbbaabaabbaaaababbbbbbbaaaaabbabaabaaaabbabbabaaabbbbabaababaabaaaaabbabbbaaababbabaababbabbababbbbaababaabbbbbbaabbababaaabbabaaaaabbbaaaaaaababbbbabbbabbaaaababbbabbbabbabbbabbbbbabbabbaaabbbababbaba...

output:

364

result:

ok 1 number(s): "364"

Test #28:

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

input:

1000
bbbbbaaaabbbbaabaaaaaaaaababbabbbabababbaabaabbababaabbabaaaabababaaabbbbababaabbbaabaaabaaaaabaabababbabbabaabbbabbaaaaaabbbbaababbaaaabababaabbaabbbabbaaaaaababaabbabaaaaaaabaaabaababaabbbabaabaabbbabbaaaabaaaababaababbabbaabbaabbaababaaabbbbbabbabababbbabbbaabbabbaabababaababbabbaaabbbaabaaa...

output:

366

result:

ok 1 number(s): "366"

Test #29:

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

input:

1000
aaaabaaaabaaabbabbbbaabaabaaabaabbabbaaaaaabbbbaaabbbbbabababbaaabbbbbbbbaaabaaaababbababbabbbabbabaabbaaaaabbbbbbbaabaababbbaabbaaaaaabbbbabbaaabbbbaaabaabbbbaaaaaaabbababbaaaabaaaabbbabbaaabbaaabbaabbaabbbbaabbabbbaaaabaaabbbbbaabbbbaaaabababbbabaabbbabbbaaabbbabbbbaabbbabbbabaaaabbabaaaabbbb...

output:

375

result:

ok 1 number(s): "375"

Test #30:

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

input:

10000
babababaaababbabbbbbabbaababaabaababbbabbaaaabaaababababbabbbababbaaaabbabbaabaabaababaabbabbaaabaaabaaaaabbbababaaabbbbaaabbaaaabaabbaaaaaabbbabbabbabababababaabbabbbbbbaaaaaaaaaaaabbbbbbaaaabbaaaaaaaaaaaabaabaabaaabbbbbaabaabbabaabaaabbabbabaabaabbababbabbaaaaabbabbabaaabbabaaaaaaabaaabbabab...

output:

3630

result:

ok 1 number(s): "3630"

Test #31:

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

input:

10000
baabababbaabbaaabbaabbabaabaaaababaabaabbbabbabababaabaaabaababbbabbaaaaabbabaabaaaabbaaaaabaabbabaabbabbbaababbabbbbaaabababbbbbabaaabbabbaaaabbaaababbbbabbbbaaabbabbbababaabbbabbbbaaabbaabaababbabaaabbabbbaaababbababbbabaabbabbbaaabaaaabaaabbbbabbabababbbaaabbbaaaabbbbabbbaabaabaabaabbabbaba...

output:

3880

result:

ok 1 number(s): "3880"

Test #32:

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

input:

10000
aaabbaabaaabbaaaaaabbaaabaabbbaaababbbaaabaabaababaababaabbbaabbabbbbbbabaabbaabaabbbbaaaabbbbbabbbbabbaabaaababbbbbabbaabbabbbbaaaaaaaaababbbbababaababbabbabbabbbababaabbbabbaabbbababaaaabaabbaababbbbbabaabbbbaaaaaababbbaaabbabaabaabbaabbabaaabaaaaaabbbaabbbbabaabbbaaaabbbbbbbaabbbabaaaabaaab...

output:

3736

result:

ok 1 number(s): "3736"

Test #33:

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

input:

10000
aaababaaababbababaaabbbbbbbabababaaaabbbbbbaabbbababbaaabbaabbbbaaabababbbbababbbbbbbabbbbabbbabbbabbabbaababbabaabbabbbaababaaaaaabbbbbabaabaaababaaaabbbbabaababbaaabbbababbbbaaabaaabbaaaaaaababbaabababbbbbaabbbaabaabbabaaabaababbabbababababaaabbbbbaaaaabbaababbaabbbbaabaaaaabbbabaabbabbbabbb...

output:

3740

result:

ok 1 number(s): "3740"

Test #34:

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

input:

10000
aaabbbabbaabbbbbaabbabbabbbbbbabaababbaaaabbaaaaaaaabababaaabbaabbaabbababaaaababbabbbaaabaabbbbbbabbababbaabbabababbaabaabaabaaabbbabaaaabbaabbbabbaaababbbbbabaabbbbbbbbbbabbbaabbbaaaabaaabbaabbaaaabbbaaabaaaaaaaaabbabbaabbabbabaaaaababababbabbabbbbbabababaabbaaabbaabbbaaabaaababbaaabaabbabab...

output:

3779

result:

ok 1 number(s): "3779"

Test #35:

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

input:

100000
ababaababaabbabaabaaababbbabaaababaaaaaababaaabaabbaaabaababaaababaabaabbbaaabbabbbbbbaaaabbbabaaaabbbaabbaaabbabaaaabaabbabbbabbbabaabaababababbaababaabbbaaabbbabababbabaaaaabbbbababbbbaabababbbabababaaabbbbaabbbabaaaaabaababbbbbabbbbbabbbbbaababbbbababababbabaabbaabbababbaabaaabaaaaabbbbbbb...

output:

37404

result:

ok 1 number(s): "37404"

Test #36:

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

input:

100000
bbaabbabbaabaaabbbbabbaaaabbbabbbababbababbaaabbababababbabbaaabbbabbbababaaaabbbbbbbbaaaaaaabaabaaaaaabaaabaababbaaaabababababbabbabaaababbaabbaaaabaabaabbbbaabbaabbaaaabaaabbbbabbabbabbaabbbbbbbbbababababbbaaabaaabbbbaaababbabbaaaabaaabbabbaaabaaababaaabbbaabababababbabbabbbbaaabbaaaaaaaaaa...

output:

37359

result:

ok 1 number(s): "37359"

Test #37:

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

input:

100000
aaaabbaaaaabbbaabbabbbbababbabbaababbababbbbbbbaabbbbabbaababbbaaaaabbbabbbaabaaaaababbbbaaaabbbabaababababbbaaaabaabbbabbaabaabababbbbbbbbbbbabbaaabbabbaabbbbabaaabbabbabbaabbabaaaaaabbbbbaabbaabaaaaabaababaababababbbababbbaabaaaabbbbbbbabbbabbaabbbbaababbaabbabbbabbbbbabbaabbabbabbbbaababab...

output:

37291

result:

ok 1 number(s): "37291"

Test #38:

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

input:

100000
ababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababa...

output:

0

result:

ok 1 number(s): "0"

Test #39:

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

input:

100000
ababababababababababbbababababababababababababababababababababababababababbbababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababa...

output:

712

result:

ok 1 number(s): "712"

Test #40:

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

input:

100000
abbbababbbababaaabaabbabbbabababababaaabababababababaaabaaabaaaaababababbbaaabababaaababababababababbbaaababbabbabababababababababbaabaabaaaababaabaaaabbabbbbababaaaaabbbaaabbbabbaababaaabaaaaabbbabababababaaabaaababababababababbbbbabaabbabbbabaaabbbabaaaaabbbabababaaabababaaababababababbbbbb...

output:

24034

result:

ok 1 number(s): "24034"

Test #41:

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

input:

100000
abaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaab...

output:

66666

result:

ok 1 number(s): "66666"

Test #42:

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

input:

100000
abaabaababbaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaababbaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaababbaabaabaabaabaabaabaabaabaab...

output:

66201

result:

ok 1 number(s): "66201"

Test #43:

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

input:

100000
bbaaababbaaaabaabaabbbbaaaaabaaaaabbabbbbaabaababbbabbbbabbbabbaaaabaabaabaabaababbaabaabaaaaaaabbaabbaaaabaabaabaabaabaaababaababbabbaabaababbaabbabaababbbbbbabaaabbbabbaababbabbaababbaabaababbabbaaaabbbabaabaababababbbbabbaabaabbabaabbbbaaaaaaaabaabaabaabaabaabaabbbbabbaabbabaabaaaaaaaaaaaa...

output:

51478

result:

ok 1 number(s): "51478"

Test #44:

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

input:

100000
babbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabba...

output:

0

result:

ok 1 number(s): "0"

Test #45:

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

input:

100000
babbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbaababbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbbbbabbabbabbabbabbabbabbabbabba...

output:

668

result:

ok 1 number(s): "668"

Test #46:

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

input:

100000
babbabbabaaababaabbababbbaababbabbabbabbaababbbbbabbaababbaababaabbabbaababbababbbabbbababbbbbabaabbbababbbbbabbaababbaaaabbbbbabbababbbabbaabbbbabbababbbabbbababbabbabaabababaababbabbabaabbabbbababbabbabbabaabbbababbbbaabbabbbbbabbabbabaabbabbabbabbabbabbabbaababbaababbabbbababbbababaaababbb...

output:

20467

result:

ok 1 number(s): "20467"