QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#245990#5474. Incredibly Cute Penguin ChicksFireball0424#AC ✓1165ms51936kbC++143.2kb2023-11-10 15:08:202023-11-10 15:08:37

Judging History

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

  • [2023-11-10 15:08:37]
  • 评测
  • 测评结果:AC
  • 用时:1165ms
  • 内存:51936kb
  • [2023-11-10 15:08:20]
  • 提交

answer

#pragma GCC optimizer("Ofast")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
//#define int long long 
#define ld long double
#define ull unsigned long long 
#define fr first
#define fi first
#define sc second
#define se second
//#define all(x) x.begin(), x.end()
#define pii pair<int,int>
using namespace std;

#ifndef fireball
#define tofu ios::sync_with_stdio(0); cin.tie(0);
#else
#define tofu freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif 

void db() {cout << '\n';}
template <typename T, typename ...U> void db(T a, U ...b) {cout << a << ' ', db(b...);}

const int N = 1e6 + 1;
const int mod = 998244353;
int pre[N * 2 + 5][3];

void add(int pos, int val, int tp){
    for (int i = pos; i < N * 2 + 5; i += i & -i) {
        pre[i][tp] += val;
        if (pre[i][tp] >= mod) pre[i][tp] -= mod;
    }
}
int query(int pos, int tp){
    int ans = 0;
    for (int i = pos; i; i -= i & -i){
        ans += pre[i][tp];
        if (ans >= mod) ans -= mod;
    }
    return ans;
}

signed main(){
    tofu;
    string s;
    cin >> s;
    int n = (int)s.length();
    int pa[n + 1] = {}, pb[n + 1] = {}, pc[n + 1] = {};
    for(int i = 0; i < n; ++i){
        pa[i + 1] = pa[i] + (s[i] == 'I');
        pb[i + 1] = pb[i] + (s[i] == 'C');
        pc[i + 1] = pc[i] + (s[i] == 'P');
    }
    vector<pair<int, int>> all[3];
    auto id = [&](int x, int pos, int t){
        return lower_bound(all[t].begin(), all[t].end(), make_pair(x, pos)) - all[t].begin() + 1;
    };

    for(int i = 1; i <= n; ++i){
        int x1 = pa[i] - pb[i] + N + 2, y1 = pc[i] - pa[i] + N + 2;
        int x2 = pa[i] - pc[i] + N + 2, y2 = pb[i] - pa[i] + N + 2;
        int x3 = pb[i] - pc[i] + N + 2, y3 = pa[i] - pb[i] + N + 2;
        all[0].push_back({x1, y1});
        all[1].push_back({x2, y2});
        all[2].push_back({x3, y3});
    }
    
    all[0].push_back({N + 2, N + 2});
    all[1].push_back({N + 2, N + 2});
    all[2].push_back({N + 2, N + 2});

    sort(all[0].begin(), all[0].end());
    sort(all[1].begin(), all[1].end());
    sort(all[2].begin(), all[2].end());

    add(id(N + 2, N + 2, 0), 1, 0);
    add(id(N + 2, N + 2, 1), 1, 1);
    add(id(N + 2, N + 2, 2), 1, 2);

    for(int i = 1; i <= n; ++i){
        int x1 = pa[i] - pb[i] + N + 2, y1 = pc[i] - pa[i] + N + 2;
        int x2 = pa[i] - pc[i] + N + 2, y2 = pb[i] - pa[i] + N + 2;
        int x3 = pb[i] - pc[i] + N + 2, y3 = pa[i] - pb[i] + N + 2;
        
        int res = query(id(x1, y1, 0) - 1, 0) - query(id(x1, 0, 0) - 1, 0);
        if(res < 0) res += mod;
        res += query(id(x2, y2, 1) - 1, 1) - query(id(x2, 0, 1) - 1, 1); 
        if(res >= mod) res -= mod;
        if(res < 0) res += mod;
        res += query(id(x3, y3, 2) - 1, 2) - query(id(x3, 0, 2) - 1, 2); 
        if(res >= mod) res -= mod;
        if(res < 0) res += mod;

        add(id(x1, y1, 0), res, 0);
        add(id(x2, y2, 1), res, 1);
        add(id(x3, y3, 2), res, 2);
        //db(i, res, query(id(x1, y1, 0) - 1, 0) - query(id(x1, 0, 0) - 1, 0), query(id(x2, y2, 1) - 1, 1) - query(id(x2, 0, 1) - 1, 1), query(id(x3, y3, 2) - 1, 2) - query(id(x3, 0, 2) - 1, 2));
        if(i == n) db(res);
    }
    
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

ICPC

output:

2 

result:

ok single line: '2 '

Test #2:

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

input:

CCCIIIPPP

output:

69 

result:

ok single line: '69 '

Test #3:

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

input:

PICCICCIPPI

output:

24 

result:

ok single line: '24 '

Test #4:

score: 0
Accepted
time: 702ms
memory: 51056kb

input:

PCPPCCICPICPCPCPCCPPIPPPIICCCICPICCPPPIPCCCCICCIICPCCICCCPCICIPPIPIPIPPCCPCIPPCCPPCCIPPPIPPCIICIIIPPCIPPICPPICCPIICCCCCCCICPCCPPIPIPICPCIICPCCIPICCCPPCPIIICPCPPPIIIIICCCPCICCPPCPPCICIIIPIPICPCPPPPICPCPIPIIICCICPCIPPICCICPIIPPCCCIICPCPCCICCPICPPPPPPICCCIPCCICICIPICIIICCICPCIPIICPIPIIICCPCCIIPCCCCPIPI...

output:

216523282 

result:

ok single line: '216523282 '

Test #5:

score: 0
Accepted
time: 699ms
memory: 51508kb

input:

ICIPCICCIPIPIIPPCPCICICPCPCPIIICICPPICCICPIPCPCIIPPIPCCIPIPIPIICCICICCCIPPIIPCPPCIIICCICCCCCCPIPICCIPIICIICPIPCCICPPCCIPIPIICCCPCCIPCPPCCIIIIIPCIPIIPICIIIPIICCCIPPPIPICIIIICIIIPICIICPIPCCICIPCCIPICCCPPIPIIPICPPCPICIPIPPPPPCIPCCIPPICIPCICPCCCCPPIIIPCPICCICIPIIPICPIIIIPPPCPIIIPCCPPIIPPICPIIICCCPICPPIC...

output:

977504498 

result:

ok single line: '977504498 '

Test #6:

score: 0
Accepted
time: 812ms
memory: 51156kb

input:

PPCCCICCIPPICCPCCCCIPPPIICPIPIPPPPIPPPPPPCPIPICCPCCPICPIPPPIIPIPIIPPCCPIICPPIIIPPCCCIIPCCIPCCCCCCIIIPIPCICCIICIIICCCCPCCICPPCCPCCIPICCPPIIPIIPIPCIIPIIPPPCCIPCPCCICCIPICPPPCIPPIPCCPCPCCIPIICCIPCCIPPCPCIPICIICPPICIIICIPIIIIIPCCCPPIPPPCIICIIIPPCIPCIPCIICCCCPIPCPICICPIPCPPIPIPICCPCCCCPCIPCPPCCIPCCCCCPII...

output:

785880133 

result:

ok single line: '785880133 '

Test #7:

score: 0
Accepted
time: 709ms
memory: 51276kb

input:

ICIPCPIPCCCCCCCPCCPCCIPCPCPIPPCPIPCICPPIPPPPICPIIPPIICPICPICPPICICICCCIIPCPPCCICCCCPIICPPPIPIPCICPIPPPPCCPICPCPICICPPIIIICIICPPIPIIICCCCPIPIIPICCCIPCCPPCPPPPIIIIICIPCPCCPIIICICIPPCCPIPPCIIPCCCIIICPCIPCIIIIPCIIPCIICCCIPPIPPCIIPCICIPIIPICCICCPCPIICCCIPIICCCPIPPCCIIIICPPIICPCPCIPPPCPCICPPIPIPCCPIPPPIPI...

output:

687587235 

result:

ok single line: '687587235 '

Test #8:

score: 0
Accepted
time: 825ms
memory: 51584kb

input:

IICCCIPIIIIIPICIICPCPCIICCIIICCCIIPICICCCPCPCPPPIIPIPPICIICICIPIICCICCIIIPCIICCPPIPICIPPCPCPCPIICCIIICIPPICCICPPIPPPPICPCPIPCCCPCPCPPPPIICPCIIIIIIIPIPIICICCPPIIPPCICPCPCIPCPICPPPICCICIICPPIPPPIPIPIPPCIPPCIPPCPPPIICICCCPICIPPIPCCPIIPPCIPPICCIIIPPPPPIIPPICPCPCIPPCCPCIIIPPICCCIIIIICIPPIIICPCIIICPPCPCPP...

output:

698376687 

result:

ok single line: '698376687 '

Test #9:

score: 0
Accepted
time: 806ms
memory: 51208kb

input:

IIPICCCCIPPCCPICCIIPPPCIPCCPPIPIICICPCCIIPPCCCICICPPICCICPPIICIIPICPICIPPPPCPCCPIICCPPIPPCIIIIPICICICCIIPPCICCCCCPICPIPCPPCCPPICPICCCICCIPICCICPIICCPIPIPICCPPCCPCPCCPICCPICCCCCCIPIICPIPICICCPIIPIPICIICIPPPIPCICIPIPPICPICICPPICICCIPCIPPPCIPIIPPPIICICPPPIICCCPIIICIPIPPICICIPPPCCPCCIIPCCCPPPCPICPICPPCP...

output:

850857669 

result:

ok single line: '850857669 '

Test #10:

score: 0
Accepted
time: 816ms
memory: 51272kb

input:

IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII...

output:

709758735 

result:

ok single line: '709758735 '

Test #11:

score: 0
Accepted
time: 837ms
memory: 51152kb

input:

PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP...

output:

854001544 

result:

ok single line: '854001544 '

Test #12:

score: 0
Accepted
time: 812ms
memory: 51296kb

input:

CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC...

output:

427000772 

result:

ok single line: '427000772 '

Test #13:

score: 0
Accepted
time: 342ms
memory: 40320kb

input:

IPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPC...

output:

717926203 

result:

ok single line: '717926203 '

Test #14:

score: 0
Accepted
time: 358ms
memory: 39832kb

input:

PCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCI...

output:

939976909 

result:

ok single line: '939976909 '

Test #15:

score: 0
Accepted
time: 342ms
memory: 39636kb

input:

CIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIPCIP...

output:

687951732 

result:

ok single line: '687951732 '

Test #16:

score: 0
Accepted
time: 767ms
memory: 51144kb

input:

IIIIIIIIICIIIIPIIIIIIIIPIIIPIIPIIIIIIIIIIIIPIIIIICIIIICIIIIIIIPCIIIIIIIIIPIIIIIIPIIIIICIIIIIIIIIIIIICIIIIIIICICIIIICIIIIIIPIIIIIIIIPIIIIIIICIIIIIPIIIIIIIIIIPCIPIICIPIIIICIIIIIIIIIIPICIIIIIPIIIIIIIIIIIIIIIPIIIIIIIIIIIIIIIIPIPPPCIPIIIICIIIIIIIIIIIIIIIIIIIICIIIIIIICIPIIIIPIIIIIIIIIIIIPIIIPICIIPIIIIIIII...

output:

955489074 

result:

ok single line: '955489074 '

Test #17:

score: 0
Accepted
time: 642ms
memory: 50988kb

input:

PPPPPPCPIPICPPPPPIPPPPPPPPPPCPPCPPPPPPPPPPPIPPPPPPPCPPPPPPPCIPICPIIPPPIPPPCCPPPPPPPPPPPPPPCPPPPPIPPCPPPPPPPPPPPPPPPCPPPPPPPIPPIPPPPPPPPPPPICIPPPPPPIIPCPPPCPPPCPPPPPPPPPPPPPICPPPPIPCPPPPPPCPIPPPPPPPPIPPPPPPPPPPPIIIPIPCPPPPPPPPPPPPPPIPPPPPPPPPPIPPPPCPPPPPPPPPPCPPIIPPPPPPPPPPPPPPPIPPPPPPPPPPPICPPPPPPPP...

output:

375091010 

result:

ok single line: '375091010 '

Test #18:

score: 0
Accepted
time: 713ms
memory: 51152kb

input:

CCCCCCCCCCCCCCCCPIPCCCCCCICCCCCCCCCCCCCICCCCCIPPCCCCCCCCCCICCCICCCCCCCCCCCCCCCCCPCCCCPCCPCCCCCCCCPCICCCCCPCICCPCCCCPCPCCCCCCCCCCCCICPCCPCPPCCCCCCCICICPCCCCCCCCCICICCCICCPPPPPCCCCPPCCICPCCCCCCCIICCPCICCCCCCCCICCCCCCCCICCICCCICCCCCCCCICCCCCCCCCCCCCCCCCIPCCCCCCCCCCICPCCCPICCCCPCCCCCCCCCCCCCCPCICICCICCC...

output:

270555678 

result:

ok single line: '270555678 '

Test #19:

score: 0
Accepted
time: 761ms
memory: 51380kb

input:

IIPIIIIIICIIPIICIIIIIIIIIIIIIPIIIPIIIIIIIIIIIIIIIIIIIIIIIIIIICIIIIIIPPIIIIIIPIIICCICIIPIICCIIPIIIPIIIIIIPIIIIIIIICIIIIIIIIIIICIIIPIIIIIICIICIIICIIIIPIICIIIPIIIIIIIPIIIIIPICIIIICICIIICIIIIIIIIIIIPICIIIIIIIIIIPPIIIICIIIIIIIIPIIIIIPIICIIIIIIICCIIPIIIICIIPIIIIIIIIIIIICIIIIIPIIPCIIIIIICICIIIIIIPIIIIIIIII...

output:

178987433 

result:

ok single line: '178987433 '

Test #20:

score: 0
Accepted
time: 648ms
memory: 51064kb

input:

PPPPPPPCIPPPPPPPCPPPPCIPPPCPPPPCPPIPPPPPPPPPPPPPCPPPPPPPPPPPIPPPPPIPPPIPPPPPPPPCCPPPPPPPPCPPPCPPPIPPPPPPPPIPPPPPPPPPPPPPPPPPPPPPPPIPPPPPPCPPIPPPPPPICPPPPPPPPCPPPPPPPPPPPPPPPCPPPPPPPCPPCPPPPPPPPPIPCPPCPPPPPPPCPIPPPPPIPPPPPPPPPPPPPCPPCIPPPCPPPPPPPPPPPPPPPPCPPPPPPPPPCPPPPPPIIPPPPPIPCPCIIPPPPPPPPPCPPPIP...

output:

328261068 

result:

ok single line: '328261068 '

Test #21:

score: 0
Accepted
time: 744ms
memory: 51284kb

input:

CCICCCCIPCCCCICCCCPCCCCCICCCCCCCCCCCCCCCICCCCPCCCCCCCCCCCCCCCICCCICCCCCCICCCCCCCCPCCCCCPPICCCCCCCICCCCCICCIIPPICCCICCCCCCCCCCICCCCCPCCCCICCCCCCICCIPCCPCIPCCCCPICPCCCCCICICCCCCCCCICPCCCPCCCPCCCPCCCCCCCCCPCPCCICPCCCCCICCPCCICCCPCCCCCCCCCCICCCCPCCCCCPCCCCCPCCCPCCCCCCCCCCCCCCCCCCCCPCICCCIICPCICPIICCCCCC...

output:

424185045 

result:

ok single line: '424185045 '

Test #22:

score: 0
Accepted
time: 778ms
memory: 51192kb

input:

IIIIIIIIIIPIIIIIIIIIIIIIIIIIICIIIIPPCIICICIPIIIIIPIIICPIIICIIPIPIIIIIIIIIIPIIIIIIIIPIPIIIPICIIIIIIPIIIIIPIIIIIIIIIIIIICIIIIPIIIIICIICICIIIIIIIIIIIIIIIIIIIIIIIIIICIPCIIIIIIPIIIIIIIIIIIIIICIIIIIIIIIIIIIIIIIIIIIIICIIIIIICIIIIIIIICCIIIIIIIIPIIIIIIIIPIIIPIIIIIICIIIIIIIIIIIIIICIIIICIIIIIIIIIPIIIIIIIIIIPII...

output:

595831650 

result:

ok single line: '595831650 '

Test #23:

score: 0
Accepted
time: 631ms
memory: 51528kb

input:

PCCPPPPCPPIPPPPCIPPPCIPCPPIPIPPPPPPIPPPIIPPPPCPPPPPPIPPPIPPPPCPPPIPPPPPPPPIPPPPIPCPPPPPPPPPIPPPPPPIIIPPPPPIPPCPPPPPIPPPPPPIPPPPPIPPPIPPPPPPCPPPPPPPPPPPPPCPPPPPPPPPPPPPPPPPIIPICPPCPPPPPCPPPPPPCPPPPPIPPPPPCCPPPPPPPIPPPPPPPPPIPPPPPICPPPPPIPPPPPIPCPPPPPPCPPPIPPPPPPPPPPCPPPPPPPPPIPPCPPPCCIIPPIIPPPPIPPPPP...

output:

354896912 

result:

ok single line: '354896912 '

Test #24:

score: 0
Accepted
time: 718ms
memory: 51224kb

input:

CPCCCCCCPPICICCPCCCCCCCCCPCCCCCCCCPPIPPCCCPCCCCCCPCICCCCCCCIPCCICICCCCCCCCCCCCCCCCCCIPCCCPCCCIPCPCCPCCPCCCCCPCCCCCCPCCCCICPCCCCCCCCCCCCCIICCCCCIPCIIICCCCCCCCPCCCCCCIICCCCCCCICPCCCCCCCCCCCICCCCIPCCCCCCCCCCPCCCICCCCPCCCCCCCCCCCCCCCPPCPCCCCICCCCCCCCCCCCCPCCCCICCCCCCCCCCIIICCCCCCCCCCCCCCCCICCCCCPCICIPIC...

output:

423510008 

result:

ok single line: '423510008 '

Test #25:

score: 0
Accepted
time: 737ms
memory: 51344kb

input:

IPCIIIIPCIIIIIICPIICPIIIIIIIICPIIIIPCICPPCPCIIIIIPCIIIIIICPIIIPCIIPCIIIIIICPIIIIIIIIIPCCPICPCPIIIIIIIIIIICPIPCIICPIIIIIIIIIIPCIIIICPIIIIIIIIIICPCPIIIIIIIIIIIIIIIIIPCIIIIIIPCIIIPCIIICPIIPCIIIPCCPPCIIIIIIIIIICPIIIIICPICPIIIIIIICPIICPIICPIIIIIIIIICPIIIIIIICPIICPIIIIIPCIIPCIIIIIIIIIIIPCIIIIIIIPCICPPCIII...

output:

803254087 

result:

ok single line: '803254087 '

Test #26:

score: 0
Accepted
time: 635ms
memory: 51224kb

input:

PPPPPPPPPPPPPPPPPPPPPPPICICPPPPPPPICPPPPCIPPPPPPICICPPPCIPPPPPCIPCIPPPCIPPICPPPPPPPCIPPPICPICPPPPPPPPPPPPPPPPPPPPICCIPPPCIPPPPPPPICCIPPPPPPPCIPPPCIPPPPPPPPPPPPICPPPPPPICPPPICPCIPPPPPPPPPPPPICCICIPPPPPPICPPPPPPPICCIPPCIPICPPPPCIPPCIPPPPPPPPPICCIPPPPPPPPPPPPCIPPPPPPPCIICPPPCIPPPCIPPCIPPICPPPPPCIPPPPCI...

output:

422010091 

result:

ok single line: '422010091 '

Test #27:

score: 0
Accepted
time: 660ms
memory: 51744kb

input:

CCPICCCCCCIPCCCCCCIPPICCCCPICCCCCCCCCCCCCCCCCCCCCIPPICCCCCCCCIPCCCCCCCCCPICCCCCCCPICCCCCCIPCIPCCCCCCCCCIPCCCCCCCCCCCPICCCCCCCCPICCIPCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCPICCPICCCPICCCPICCCCCCIPCIPCPICCCCCCCCIPCCCCCIPCCCCCCCCCCCCCPICCCCCCCCCCCCCIPCCCCCCPICCCCCCCCCCCCIPPICCCCPICCPICCCPICCCPICCPICIPCPICCCCCCC...

output:

81666193 

result:

ok single line: '81666193 '

Test #28:

score: 0
Accepted
time: 731ms
memory: 51832kb

input:

CPIIIIIICPIIIIICPPCIIPCCPIIIIIIICPPCIIIIIIIIIIIIIICPIIIIIIIIIIPCIIIIIIIIPCIIPCIPCIIPCIIIIIIIIIIICPIIICPPCIIIIIIIIIIIIICPIIIIIIIPCIIIIIIIIIIIIIIIIIIIIIIIIIPCIIIIIICPICPPCIIIIIIICPIIIPCICPIIIIICPCPICPIIIIIICPPCIIIIICPIIIIIIIICPIIPCIIIIIIIIIIIICPICPIIICPIIIIPCIICPIIPCIIPCIICPIIIIIIICPCPIIIIPCCPIIIIIPCC...

output:

739418046 

result:

ok single line: '739418046 '

Test #29:

score: 0
Accepted
time: 561ms
memory: 51340kb

input:

PCIPPPPPICPPPCIPPPPPCIPPPPPPPICPPPPPICPPPPPPPPCIICPPPPPICCIPPCIPPPPPPPICPPPPPPPPPPPPICCIPPPPPPCIPPPPPPPPPPPPPICPCIPPPPCIPPPICPICPPPPCIPPICPPPPPPPCIPPCIPCIPPPPPPPICPCIPICPPPICCIPPPPICPCIPPPPPPICPPPCIPPCIPPPPPPPPPPPPPPICICCIPPICPICPPPPCIPPPPICPPPPPPPPPPPPPPPPPPPPPPPICICPPPPPPPPPCIPCIPPPPPCIPPPCIICPICP...

output:

429005526 

result:

ok single line: '429005526 '

Test #30:

score: 0
Accepted
time: 670ms
memory: 51244kb

input:

PICIPCIPCCCCIPCCCIPCCIPCIPCCCCCCIPCCCCCCCCCCCCCCCCCIPPICCCCIPCCCCCCCCCIPCPICCCCCPICCCPIPICPICCCCCCIPCCPICIPCCIPCCCCCPICCCCCCCIPCCCIPCCCCCCPICCCCCCCPICCCCCCCCCCCIPCCCCCCCCCCCPICCCCCCCIPCIPCCPIPICCCIPCCCCCCCCCCCCCCCCCIPCCCCPICCIPCIPCCCCCCCIPCIPCCIPPICCCPICCPICCCCCCCPICCPICIPCCCCCPICCCCCPICCCCCCCPICCCC...

output:

346033550 

result:

ok single line: '346033550 '

Test #31:

score: 0
Accepted
time: 1073ms
memory: 51316kb

input:

IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII...

output:

876361609 

result:

ok single line: '876361609 '

Test #32:

score: 0
Accepted
time: 1102ms
memory: 51036kb

input:

PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP...

output:

51133400 

result:

ok single line: '51133400 '

Test #33:

score: 0
Accepted
time: 1141ms
memory: 51344kb

input:

CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC...

output:

881510334 

result:

ok single line: '881510334 '

Test #34:

score: 0
Accepted
time: 1080ms
memory: 51312kb

input:

IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII...

output:

703358165 

result:

ok single line: '703358165 '

Test #35:

score: 0
Accepted
time: 1110ms
memory: 51176kb

input:

PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP...

output:

8597778 

result:

ok single line: '8597778 '

Test #36:

score: 0
Accepted
time: 1150ms
memory: 51236kb

input:

CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC...

output:

875167427 

result:

ok single line: '875167427 '

Test #37:

score: 0
Accepted
time: 1159ms
memory: 51160kb

input:

IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII...

output:

339337501 

result:

ok single line: '339337501 '

Test #38:

score: 0
Accepted
time: 1165ms
memory: 51188kb

input:

PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP...

output:

321201785 

result:

ok single line: '321201785 '

Test #39:

score: 0
Accepted
time: 1156ms
memory: 51128kb

input:

CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC...

output:

654943659 

result:

ok single line: '654943659 '

Test #40:

score: 0
Accepted
time: 816ms
memory: 51672kb

input:

IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII...

output:

995448234 

result:

ok single line: '995448234 '

Test #41:

score: 0
Accepted
time: 783ms
memory: 51504kb

input:

PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP...

output:

442950961 

result:

ok single line: '442950961 '

Test #42:

score: 0
Accepted
time: 829ms
memory: 51424kb

input:

CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC...

output:

221475480 

result:

ok single line: '221475480 '

Test #43:

score: 0
Accepted
time: 817ms
memory: 51180kb

input:

IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII...

output:

828731448 

result:

ok single line: '828731448 '

Test #44:

score: 0
Accepted
time: 798ms
memory: 51464kb

input:

PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP...

output:

967126854 

result:

ok single line: '967126854 '

Test #45:

score: 0
Accepted
time: 792ms
memory: 51756kb

input:

CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC...

output:

898792666 

result:

ok single line: '898792666 '

Test #46:

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

input:

I

output:

1 

result:

ok single line: '1 '

Test #47:

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

input:

P

output:

1 

result:

ok single line: '1 '

Test #48:

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

input:

C

output:

1 

result:

ok single line: '1 '

Test #49:

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

input:

IP

output:

1 

result:

ok single line: '1 '

Test #50:

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

input:

PP

output:

2 

result:

ok single line: '2 '

Test #51:

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

input:

CP

output:

1 

result:

ok single line: '1 '

Test #52:

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

input:

IP

output:

1 

result:

ok single line: '1 '

Test #53:

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

input:

PP

output:

2 

result:

ok single line: '2 '

Test #54:

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

input:

CP

output:

1 

result:

ok single line: '1 '

Test #55:

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

input:

IP

output:

1 

result:

ok single line: '1 '

Test #56:

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

input:

PP

output:

2 

result:

ok single line: '2 '

Test #57:

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

input:

CC

output:

2 

result:

ok single line: '2 '

Test #58:

score: 0
Accepted
time: 635ms
memory: 51048kb

input:

CICCCPPIICCCIPPPCPCCCPPICCIPPIPPCICPCCPPCCICPPPPPIIPPPCIPPPCCPPCPPPIPCPICPPPCPPPPPCIPIPCPPCCCCCCICPICPCPPPICIPPCPCPIPCCPPCPCPPCCCCIPPIICPPIICPPCPPIIPCICPPPCIICPCCCCPPPCCCCICCICIPCIPCPPPPCCCIPCCICPCCCCPCPICCCCCCPCPCPPCCPCPCPCCPIPPICPPIPPCCCPPICCCPPPPPCCPCICCPPCCCIIPPPIICCPCCPPCCIPCCCICCPPPICPCCPPICIC...

output:

382266009 

result:

ok single line: '382266009 '

Test #59:

score: 0
Accepted
time: 785ms
memory: 51732kb

input:

PICCPIIICICPICIIIPICPICCIPPIPPPCCCIIPIIPCIPCCIIIICPIIPPIPICCPIPCPIPPPPPICIICIICIICICICIPCIIICCIPCICIPCICPICCPCCICICCCIICPIPICPPPPICIPCCIIIIIIPCCICIIPCPICCCCPCICPIIIIPCCCCPICICCCICIPIIICICPIPCIPPIIPCIPIICICPICCIICICCCPCPCICCPICICIIICCCIPICCIIPIIPIICCICIPIPCCCCCIICPIIICIPIICICPIICICIPPPCIIICCCCPICICCC...

output:

510412653 

result:

ok single line: '510412653 '

Test #60:

score: 0
Accepted
time: 734ms
memory: 51936kb

input:

ICPCCIPPIPCIPCICPCCCIPCPPPPPPICPCPIPIIIPPCIIPIIPIPCCIIIIIIIIPICIIIPIPIIICIPICIIIIIICIIPICCCPIPIPCCPPCCPIPCICCIIPCPPIIIPPIICPIPIPPPPCIPIPIIPIIIICCPICIPCPCPCPPCICIPPICIIIPPPPPPCCIPIPICPCCICCCPICIPPIPPIPPPICPIPPCPCIIIPIPCPIICIIPIIIPCPPPICPICPIPIIIIIIICICIIPIIIPPIPIPICPPIIIIPCICICICCIIPPIIPIPCCCIPIPCCII...

output:

130104659 

result:

ok single line: '130104659 '

Test #61:

score: 0
Accepted
time: 594ms
memory: 51168kb

input:

CPIPCCPPCPCCPCPIIPCCPPCPCCPPCPCCPCPPCCPCPPCCPPCCPPCPCICPPCPCCPCPCPPCPCIIPCCPCPCPCPPCICPPCPCPCIPCPCPCCPPCCPCPCPPCCPIPCICPPCCPPCCPIPCPCPCCPPCPCCPIIPCICPPCCPPCIPCPCICPPCPCPCIICPPCPCPCPCCPCPPCPCPCICPIIPCIPCPCCPCPPCCPICPICPPCCPCPIPCICPCPPCPCICPPCCPCPCPCPPCCPPCCPPCPCPCCPCPCPICPPCPCCPICPPCPCCPCPCPIPCPCPCCP...

output:

892362548 

result:

ok single line: '892362548 '

Test #62:

score: 0
Accepted
time: 745ms
memory: 51176kb

input:

CIICPPICICPICCIICPICCIPCICICIPICICICPCIPCICICICICIICPICICICICICCICIICCICICIICICICCIPCIPCIPCIICCIPPICPICPCICIICPICCIICCIICCICIICCIICICCIPCICICIICCIICCICIICCICICIICPPICCIICICCIICPCIPCIICCICICIICICICICICCIPICICCIPPCIICCIICPCIICICCICIICCIICICICICICPICICICICICICCICIPCICICICIPCIICICCICICICIICICPCICICIICCI...

output:

249936867 

result:

ok single line: '249936867 '

Test #63:

score: 0
Accepted
time: 692ms
memory: 51424kb

input:

PIIPCIPCPIPICIPIPPIIPIPIPIPPICCIPIPPIIPIPPICCIPCIPPIIPCIPIPPIPIPIIPPIIPPIPICIPPIPIPIPICIPCIPIPPIPIIPIPPIPIIPPIPIPIIPPIIPPIPIPIPIIPCPIIPPICIPIPIPCIPCIPPIPIPICCPIPICIPIPPIPICCIPPIIPPIPICCIPPIPIPIIPIPIPCIPPIIPPIPICPICCPIPIIPPIPIIPCIPPIIPPIIPIPIPIPIPPICCCCIPIPIPIPCPIIPCIPPIIPCIPPICIPCIPCPIPIPIIPCIPPIPIP...

output:

278587043 

result:

ok single line: '278587043 '