QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#706671 | #9454. String of CCPC | chimu | AC ✓ | 15ms | 5024kb | C++20 | 1.4kb | 2024-11-03 12:54:00 | 2024-11-03 12:54:00 |
Judging History
answer
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
using namespace std;
int main()
{
cin.tie(0),cout.sync_with_stdio(0);
int t;
cin >> t;
while(t--)
{
int n;
cin >> n;
string a;
cin >> a;
vector<int> b(n , 0);
int re = 0 , ju = 0;
for(int i = 0 ; i < n - 3 ; i++)
{
if(i < n - 3)
{
if(a[i] == 'C' && a[i + 1] == 'C'
&& a[i + 2] == 'P' && a[i + 3] == 'C')
{
b[i] = b[i + 1] = b[i + 2] = 1;
i += 2;
re++;
continue;
}
}
}
for(int i = 0 ; i < n - 2 ; i++)
{
if(b[i] != 1 && b[i + 1] != 1 && i < n - 2)
{
if(a[i] == 'C' && a[i + 1] == 'C' && a[i + 2] == 'C')
{
ju = 1;
i += 2;
}
else if(a[i] == 'C' && a[i + 1] == 'C' && a[i + 2] == 'P')
{
ju = 1;
i += 2;
}
else if(a[i] == 'C' && a[i + 1] == 'P' && a[i + 2] == 'C')
{
ju = 1;
i += 2;
}
}
}
cout << re + ju << endl;
}
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3776kb
input:
3 3 CCC 5 CCCCP 4 CPCP
output:
1 1 1
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 15ms
memory: 5024kb
input:
20003 5 PCCPC 10 CPPPPCPCPC 4 CPPC 11 CCPPCPPPCCP 17 PPPPCPCCCCCPCCCCC 10 PPCCPCPPCP 9 CPCCCCPPC 11 PCPPPPCCPPP 15 CPCPPPPCCPCPCCC 11 PCCPPCCPCPP 9 PCPCCPPCP 10 CCPCPPPCPP 14 CCCCPPPCPCPCPP 2 CC 12 CCPCPPPPPCPP 6 CPPPPP 12 PCCPCCCCCPCC 16 CPCCPCCPPCCCCPPC 7 CPPPCPC 16 PPPPPCCPCPCPCPPC 13 PPPCPCCCCPP...
output:
1 1 0 1 2 1 1 1 2 2 1 1 1 0 1 0 3 2 1 2 1 2 2 0 1 2 3 1 1 3 1 2 2 1 0 0 0 3 1 0 0 1 1 2 0 1 1 0 1 2 0 1 0 1 0 3 1 1 0 2 1 3 2 2 0 2 2 0 0 2 1 1 3 3 1 3 1 2 0 1 1 0 1 2 2 1 1 2 1 3 1 1 3 1 2 2 0 1 0 3 0 1 1 2 2 0 2 1 1 2 2 0 3 1 1 1 1 2 1 2 0 1 1 0 3 0 3 1 1 0 0 1 0 3 0 1 1 1 1 2 2 1 1 0 0 1 2 0 1 2 ...
result:
ok 20003 lines
Extra Test:
score: 0
Extra Test Passed