QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#808191#78. Eggfruit CakeLaVuna47#AC ✓1ms3996kbC++171.7kb2024-12-10 17:48:232024-12-10 17:48:24

Judging History

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

  • [2024-12-10 17:48:24]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3996kb
  • [2024-12-10 17:48:23]
  • 提交

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

// k = 4
// ***E****E
int solve()
{
	string s;
	if(!(cin>>s))return 1;
	int n=sz(s);
	FOR(i,0,n)s.pb(s[i]);
	int k;
	cin>>k;
	int e=0;
	ll res=0;
	for(int l=0,r=0;l<n;++l)
	{
		while(r<2*n && e==0)
		{
			if(s[r]=='E')++e;
			++r;
		}
		if(e>0 && r-l<=k)
		{
			res += l+k-r+1;
		}
		if(s[l]=='E')--e;
	}
	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
}

詳細信息

Test #1:

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

input:

PEPEP
2

output:

6

result:

ok single line: '6'

Test #2:

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

input:

PPPPPPPPPPPPPPPPPPPP
10

output:

0

result:

ok single line: '0'

Test #3:

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

input:

EEEEEEEEEEEEEEEEEEEEE
11

output:

231

result:

ok single line: '231'

Test #4:

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

input:

PPPPPPPPPPPPPPPPPPPPPP
12

output:

0

result:

ok single line: '0'

Test #5:

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

input:

PPEEPPEPEEPPPEPEEEPEEEP
13

output:

281

result:

ok single line: '281'

Test #6:

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

input:

PPPPPPPPPPPPPPPPPPPPPPPP
14

output:

0

result:

ok single line: '0'

Test #7:

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

input:

PEEEPEEPEPPPPEEEPPPEEPPEP
15

output:

351

result:

ok single line: '351'

Test #8:

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

input:

PEPPPEPPEEPEPPPPPEPPEPPPPE
16

output:

377

result:

ok single line: '377'

Test #9:

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

input:

PPEPPPPPPPPPPEEPPEPPPPPPEPEPPPEPPPEEPPEPEPPPEEPPPPPEPPPPPEEPEPPPPEEEPPPEPPPPEEEPEPEPPEEPPEPEEPPPEPPPPPPPPEPPEPPPPPEEPPEPEEPPPPPEPPPPEPEPPPPEPEPPPPEPEPPPPPPPEPPEEPPPEPPEPEEPPEEEEEEPEPPPEPEPPEEEEEPEPPPEEEPPEPEPPPEPPPPEEPEEPPPPEPPEPPPPPPPPPPPPEPPPEPPPPPPEPPEPPEPPPPPPPEPPEPPPEPEEPPEPEPPPPEPPPEPEEEPPPPPP...

output:

9797610

result:

ok single line: '9797610'

Test #10:

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

input:

EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE...

output:

9999900000

result:

ok single line: '9999900000'

Test #11:

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

input:

EPPPPPEEPPPPPEPPEEPPEPPPPEEPPPPPPPPPPPPPPPEPPPPPPPEPPPPEPPPEEPPPPEPPEPEPEPPEPPEPPPPPPPPPPPEPPPPPPPPPEPEEPPPPPPEPPEPPPPPPPPPEPEPEPPPPPPPPPPPPPEPEEPEPEPPEPPEEPPPEEEPPEPPPPEPEEPPPPPPPPPPPEPPPPPPPEPPPPPPEPPPEPPPPEPPPPPPEPPEEEPEPPEPPPPPPPPPEEPEPPPEPPPPEEEEEPPPPPEPPEPPPPPPPPEPPEPEPPEPPPPPPEPPPPPPPEPPEPPPP...

output:

6285741

result:

ok single line: '6285741'

Test #12:

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

input:

EPE
1

output:

2

result:

ok single line: '2'

Test #13:

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

input:

EEEPEEEEEPEEEEEPEEEPPEEEEEEEEPEEEEEEEEPEPEEPEEEEEEPPEEEEEEEPEEEEEEEEEPEEPEEEEPEEPEEPPEPEEEEPEEEPEEEEEEEEEEEEEEEEEPEEEPEEEEEEEPEPEPEPEEEEEEPEEEEEEEEEEEEEEEEEEEPPEEEEEEEEEEEEEEEEEEEEEPEPEEPEEEEPEEEEEEEEEEEEEPEEEEEEEEEEEEEEPPEEEPEPEEEPEEEEPEEEPEEPEEEEEEEEEEEEPPEEEEEEEEEEEEEEEEEEPEPEEEEEEEEEEEPEPEEEPEPE...

output:

6859883263

result:

ok single line: '6859883263'

Test #14:

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

input:

PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPEPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP...

output:

2441378840

result:

ok single line: '2441378840'

Test #15:

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

input:

PPPPPPPPPPPPPPPPPPPPPPPPPEPPPPPPPPPPEPEPPPPPPPPPPPEPEPPPPPPPPPPPPPPPPPPPPPPEPPPPPPPPPPPPPPEPPPPPPPPPPEEPPPPEPPPPPPPPPPPPPPPPPEPPPPPPPPPPPPPPPPPPEPPPPPPPPPPPPPPPEEPPPPPPPPPPPPPEPPPPEEPPPEPPPPPPPPPPPPPPPPPPPEPPPEPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPEPEPPPEPPPPPPPEPPPPPPPPPPPPPPPEPPPPPPPPPPPPEPPPPPPPPPEPPP...

output:

7835156010

result:

ok single line: '7835156010'

Test #16:

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

input:

EEPPEEEEPPEPPEPPPPPEPPEEEEEEEPEEEPEEEPPEPEEPEEPEEEPEEEPEPPEPEEEEPEEEPEPPPEPPPPEPEPPPEPEPEPPPEEEEPEEPPPPPEPEPEPEPEEPPEEPPEPEPPPEEPPEPPPPEPEPEEEPPPEPPEEPEPEPEEEEEEEEPPEPPPPPEEEEEEPEEPEEPPEEPPEEEEEEEEEPPPPPPEEEPEPEPEPEEEEEEPPPEEPEEPPEPPEPEEEPPEEPEEEEEEPPEPEEEPEPPPEPPEPPEEEEEPPEEPPEPEPEEPEPPEEEPEEPPEPEP...

output:

5330324036

result:

ok single line: '5330324036'

Test #17:

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

input:

EEEEEEEEEEPEEEEEEEEEPEEEEEEPEPEEEEEEEEEEEEPEEEEEEEEEEPEEEEEEEEEEEEEEEEEEEEEPEEEEEEEEEEEEEEEEEEEEEEEPEEEEPEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEPEEEEEEEEEEEEEEEEEEEEEEEPEEEEEEEEEEEEPEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEPEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE...

output:

9062395582

result:

ok single line: '9062395582'

Test #18:

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

input:

PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPEPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP...

output:

2481607

result:

ok single line: '2481607'

Test #19:

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

input:

EEEEEEPPEEEEEEEEEEEEEEEEEEEEPEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEPEEEPPEEEEEEEEEEEEEEEEEEEEEEEEEEEPPEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEPEEEEEEEEEEEEEEEEEEEEPEEEEEEEEEEEPEEPEEEEEEEEEEEPEEEEEEEEEEEEEEEEEEEEEEEEEPEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEPE...

output:

8294039

result:

ok single line: '8294039'

Test #20:

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

input:

PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP...

output:

8086241960

result:

ok single line: '8086241960'

Test #21:

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

input:

EEEEEEEEEEPEEEEPEEEEPEEEEEEPEPEEEEEEEEEEEEPPEEEEEEEEEPEEEEEEEEEEEEEEEEEEEEEPEPEEEEEPEEEEEEEEEEEEEEEPEEEEPEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEPEEEEEEEEEEEEEEEEEEEEEEEPEEEEEEEEEEEEPEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEPEEEEEEEEEEEPEEEEEEEEEEEEEEEEEEEEEPEEEEEPEEPEEEEEEEEE...

output:

8097991676

result:

ok single line: '8097991676'

Test #22:

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

input:

PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP...

output:

0

result:

ok single line: '0'

Test #23:

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

input:

PPPP
1

output:

0

result:

ok single line: '0'

Test #24:

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

input:

EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE...

output:

3579500000

result:

ok single line: '3579500000'

Test #25:

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

input:

EPEP
2

output:

6

result:

ok single line: '6'

Test #26:

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

input:

EEE
1

output:

3

result:

ok single line: '3'

Test #27:

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

input:

PPP
1

output:

0

result:

ok single line: '0'

Test #28:

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

input:

PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP...

output:

7000050000

result:

ok single line: '7000050000'

Test #29:

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

input:

PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP...

output:

6500050000

result:

ok single line: '6500050000'

Test #30:

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

input:

PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP...

output:

5000050000

result:

ok single line: '5000050000'