QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#690106#9454. String of CCPCPHarrAC ✓23ms3924kbC++20710b2024-10-30 20:18:132024-10-30 20:18:13

Judging History

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

  • [2024-10-30 20:18:13]
  • 评测
  • 测评结果:AC
  • 用时:23ms
  • 内存:3924kb
  • [2024-10-30 20:18:13]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

using i32 = int32_t;
using i64 = long long;

#define int i64

using vi = vector<int>;
const int inf = LLONG_MAX / 2;

void solve() {
	int n;
	cin >> n;

	string s;
	cin >> s;

	int res = 0, f = 0;

	for(int i = 0; i < n; i ++) {
		if(s.substr(i, 4) == "CCPC") {
			res ++;
			i += 2;
		} else if(f == 0) {
			if(s.substr(i, 3) == "CPC") {
				res ++, f = 1;
			} else if(s.substr(i, 3) == "CCP") {
				res ++, f = 1;
			} else if(s.substr(i, 3) == "CCC" and s.substr(i + 1, 4) != "CCPC") {
				res ++, f = 1;
			}
		} 
	}
	cout << res << "\n";
}

i32 main() {
	int T;
	cin >> T;
	
	while(T --)
		solve();
	return 0;
}

这程序好像有点Bug,我给组数据试试?

详细

Test #1:

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

input:

3
3
CCC
5
CCCCP
4
CPCP

output:

1
1
1

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 23ms
memory: 3924kb

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