CSES - Putka Open 2020 – 4/5 - Results
Submission details
Task:Peli
Sender:mango_lassi
Submission time:2020-11-08 20:02:17 +0200
Language:C++11
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED35
#2ACCEPTED65
Test results
testverdicttimegroup
#1ACCEPTED0.01 s1, 2details
#2ACCEPTED0.01 s2details

Code

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int t;
	cin >> t;
	for (int ti = 0; ti < t; ++ti) {
		string str;
		cin >> str;
		int n = str.size();

		int a = n, b = 0;
		for (int i = 0; i < n; ++i) {
			if (str[i] == 'P') {
				a = min(a, i);
				b = max(b, i);
			}
		}
		if ((b - a) & 1) cout << 2 << '\n';
		else cout << 1 << '\n';
	}
}

Test details

Test 1

Group: 1, 2

Verdict: ACCEPTED

input
100
PP.
P......P.
.PP
..P.P.
...

correct output
2
2
2
1
2
...

user output
2
2
2
1
2
...

Test 2

Group: 2

Verdict: ACCEPTED

input
100
.................................

correct output
2
1
2
1
1
...

user output
2
1
2
1
1
...