QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#53957#78. Eggfruit Cakenot_so_organicAC ✓5ms4380kbC++201.4kb2022-10-06 13:40:072022-10-06 13:40:07

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-06 13:40:07]
  • 评测
  • 测评结果:AC
  • 用时:5ms
  • 内存:4380kb
  • [2022-10-06 13:40:07]
  • 提交

answer

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#define _CRT_SECURE_NO_WARNINGS
#define fast ios::sync_with_stdio(false); cin.tie(0);
#define foru(i, k, n) for (int i = k; i < n; i++)
#define ford(i, k, n) for (int i = k; i >= n; i--)
#define ff first
#define ss second

#include <iostream>
#include <algorithm>
#include <vector>
#include <bitset>
#include <stack>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <numeric>
#include <iomanip>
#include <string>
#include <chrono>
#include <complex>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef long double ld;
typedef vector<int> vi;
typedef pair<ld, ld> pld;



int main() {
    fast;
    string s;
    ll m;
    cin >> s >> m;
    int n = s.length();
    vector<int> cr(n, 1e9);
    queue<int> q;
    foru(i, 0, n) {
        if (s[i] == 'E') {
            q.push(i);
            cr[i] = 0;
        }
    }
    while (!q.empty()) {
        int pos = q.front(), amt = cr[pos]; q.pop();
        pos--;
        if (pos < 0)pos += n;
        if (cr[pos] == 1e9) {
            cr[pos] = amt + 1;
            q.push(pos);
        }
    }
    ll tot = 0;
    foru(i, 0, n) {
        tot += max(0LL, m - cr[i]);
    }
    cout << tot;
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 3620kb

input:

PEPEP
2

output:

6

result:

ok single line: '6'

Test #2:

score: 0
Accepted
time: 2ms
memory: 3556kb

input:

PPPPPPPPPPPPPPPPPPPP
10

output:

0

result:

ok single line: '0'

Test #3:

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

input:

EEEEEEEEEEEEEEEEEEEEE
11

output:

231

result:

ok single line: '231'

Test #4:

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

input:

PPPPPPPPPPPPPPPPPPPPPP
12

output:

0

result:

ok single line: '0'

Test #5:

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

input:

PPEEPPEPEEPPPEPEEEPEEEP
13

output:

281

result:

ok single line: '281'

Test #6:

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

input:

PPPPPPPPPPPPPPPPPPPPPPPP
14

output:

0

result:

ok single line: '0'

Test #7:

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

input:

PEEEPEEPEPPPPEEEPPPEEPPEP
15

output:

351

result:

ok single line: '351'

Test #8:

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

input:

PEPPPEPPEEPEPPPPPEPPEPPPPE
16

output:

377

result:

ok single line: '377'

Test #9:

score: 0
Accepted
time: 5ms
memory: 4040kb

input:

PPEPPPPPPPPPPEEPPEPPPPPPEPEPPPEPPPEEPPEPEPPPEEPPPPPEPPPPPEEPEPPPPEEEPPPEPPPPEEEPEPEPPEEPPEPEEPPPEPPPPPPPPEPPEPPPPPEEPPEPEEPPPPPEPPPPEPEPPPPEPEPPPPEPEPPPPPPPEPPEEPPPEPPEPEEPPEEEEEEPEPPPEPEPPEEEEEPEPPPEEEPPEPEPPPEPPPPEEPEEPPPPEPPEPPPPPPPPPPPPEPPPEPPPPPPEPPEPPEPPPPPPPEPPEPPPEPEEPPEPEPPPPEPPPEPEEEPPPPPP...

output:

9797610

result:

ok single line: '9797610'

Test #10:

score: 0
Accepted
time: 2ms
memory: 4300kb

input:

EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE...

output:

9999900000

result:

ok single line: '9999900000'

Test #11:

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

input:

EPPPPPEEPPPPPEPPEEPPEPPPPEEPPPPPPPPPPPPPPPEPPPPPPPEPPPPEPPPEEPPPPEPPEPEPEPPEPPEPPPPPPPPPPPEPPPPPPPPPEPEEPPPPPPEPPEPPPPPPPPPEPEPEPPPPPPPPPPPPPEPEEPEPEPPEPPEEPPPEEEPPEPPPPEPEEPPPPPPPPPPPEPPPPPPPEPPPPPPEPPPEPPPPEPPPPPPEPPEEEPEPPEPPPPPPPPPEEPEPPPEPPPPEEEEEPPPPPEPPEPPPPPPPPEPPEPEPPEPPPPPPEPPPPPPPEPPEPPPP...

output:

6285741

result:

ok single line: '6285741'

Test #12:

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

input:

EPE
1

output:

2

result:

ok single line: '2'

Test #13:

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

input:

EEEPEEEEEPEEEEEPEEEPPEEEEEEEEPEEEEEEEEPEPEEPEEEEEEPPEEEEEEEPEEEEEEEEEPEEPEEEEPEEPEEPPEPEEEEPEEEPEEEEEEEEEEEEEEEEEPEEEPEEEEEEEPEPEPEPEEEEEEPEEEEEEEEEEEEEEEEEEEPPEEEEEEEEEEEEEEEEEEEEEPEPEEPEEEEPEEEEEEEEEEEEEPEEEEEEEEEEEEEEPPEEEPEPEEEPEEEEPEEEPEEPEEEEEEEEEEEEPPEEEEEEEEEEEEEEEEEEPEPEEEEEEEEEEEPEPEEEPEPE...

output:

6859883263

result:

ok single line: '6859883263'

Test #14:

score: 0
Accepted
time: 2ms
memory: 3844kb

input:

PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPEPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP...

output:

2441378840

result:

ok single line: '2441378840'

Test #15:

score: 0
Accepted
time: 4ms
memory: 3776kb

input:

PPPPPPPPPPPPPPPPPPPPPPPPPEPPPPPPPPPPEPEPPPPPPPPPPPEPEPPPPPPPPPPPPPPPPPPPPPPEPPPPPPPPPPPPPPEPPPPPPPPPPEEPPPPEPPPPPPPPPPPPPPPPPEPPPPPPPPPPPPPPPPPPEPPPPPPPPPPPPPPPEEPPPPPPPPPPPPPEPPPPEEPPPEPPPPPPPPPPPPPPPPPPPEPPPEPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPEPEPPPEPPPPPPPEPPPPPPPPPPPPPPPEPPPPPPPPPPPPEPPPPPPPPPEPPP...

output:

7835156010

result:

ok single line: '7835156010'

Test #16:

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

input:

EEPPEEEEPPEPPEPPPPPEPPEEEEEEEPEEEPEEEPPEPEEPEEPEEEPEEEPEPPEPEEEEPEEEPEPPPEPPPPEPEPPPEPEPEPPPEEEEPEEPPPPPEPEPEPEPEEPPEEPPEPEPPPEEPPEPPPPEPEPEEEPPPEPPEEPEPEPEEEEEEEEPPEPPPPPEEEEEEPEEPEEPPEEPPEEEEEEEEEPPPPPPEEEPEPEPEPEEEEEEPPPEEPEEPPEPPEPEEEPPEEPEEEEEEPPEPEEEPEPPPEPPEPPEEEEEPPEEPPEPEPEEPEPPEEEPEEPPEPEP...

output:

5330324036

result:

ok single line: '5330324036'

Test #17:

score: 0
Accepted
time: 4ms
memory: 4144kb

input:

EEEEEEEEEEPEEEEEEEEEPEEEEEEPEPEEEEEEEEEEEEPEEEEEEEEEEPEEEEEEEEEEEEEEEEEEEEEPEEEEEEEEEEEEEEEEEEEEEEEPEEEEPEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEPEEEEEEEEEEEEEEEEEEEEEEEPEEEEEEEEEEEEPEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEPEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE...

output:

9062395582

result:

ok single line: '9062395582'

Test #18:

score: 0
Accepted
time: 3ms
memory: 3852kb

input:

PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPEPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP...

output:

2481607

result:

ok single line: '2481607'

Test #19:

score: 0
Accepted
time: 4ms
memory: 4168kb

input:

EEEEEEPPEEEEEEEEEEEEEEEEEEEEPEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEPEEEPPEEEEEEEEEEEEEEEEEEEEEEEEEEEPPEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEPEEEEEEEEEEEEEEEEEEEEPEEEEEEEEEEEPEEPEEEEEEEEEEEPEEEEEEEEEEEEEEEEEEEEEEEEEPEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEPE...

output:

8294039

result:

ok single line: '8294039'

Test #20:

score: 0
Accepted
time: 4ms
memory: 3864kb

input:

PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP...

output:

8086241960

result:

ok single line: '8086241960'

Test #21:

score: 0
Accepted
time: 3ms
memory: 4380kb

input:

EEEEEEEEEEPEEEEPEEEEPEEEEEEPEPEEEEEEEEEEEEPPEEEEEEEEEPEEEEEEEEEEEEEEEEEEEEEPEPEEEEEPEEEEEEEEEEEEEEEPEEEEPEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEPEEEEEEEEEEEEEEEEEEEEEEEPEEEEEEEEEEEEPEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEPEEEEEEEEEEEPEEEEEEEEEEEEEEEEEEEEEPEEEEEPEEPEEEEEEEEE...

output:

8097991676

result:

ok single line: '8097991676'

Test #22:

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

input:

PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP...

output:

0

result:

ok single line: '0'

Test #23:

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

input:

PPPP
1

output:

0

result:

ok single line: '0'

Test #24:

score: 0
Accepted
time: 3ms
memory: 4256kb

input:

EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE...

output:

3579500000

result:

ok single line: '3579500000'

Test #25:

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

input:

EPEP
2

output:

6

result:

ok single line: '6'

Test #26:

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

input:

EEE
1

output:

3

result:

ok single line: '3'

Test #27:

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

input:

PPP
1

output:

0

result:

ok single line: '0'

Test #28:

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

input:

PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP...

output:

7000050000

result:

ok single line: '7000050000'

Test #29:

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

input:

PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP...

output:

6500050000

result:

ok single line: '6500050000'

Test #30:

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

input:

PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP...

output:

5000050000

result:

ok single line: '5000050000'