CSES - Putka Open 2020 – 4/5 - Results
Submission details
Task:Peli
Sender:hltk
Submission time:2020-11-06 18:23:31 +0200
Language:C++17
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
Test results
testverdicttimegroup
#10.01 s1, 2details
#20.02 s2details

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:34:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&tc);
  ~~~~~^~~~~~~~~~
input/code.cpp:36:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s",s);
   ~~~~~^~~~~~~~

Code

#include<bits/stdc++.h>
#define sz(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
using namespace std;
using pi = pair<int,int>;
using lint = long long;
const int MAXN = 105;

int n;
char s[MAXN];
int memo[MAXN][MAXN][4];

int winner(int a, int b, int c){
	if(memo[a][b][c] != -1) return memo[a][b][c];
	int &r = memo[a][b][c];
	r = 0;
	if(a - 1 >= 0 && c != 1 && !winner(a-1, b, 0)){
		return r = 1;
	}
	if(a + 1 < b && c != 0 && !winner(a+1, b, 1)){
		return r = 1;
	}
	if(a < b - 1 && c != 2 && !winner(a, b - 1, 3)){
		return r = 1;
	}
	if(b + 1 < n && c != 3 && !winner(a, b + 1, 2)){
		return r = 1;
	}
	return r;
}

int main(){
	int tc;
	scanf("%d",&tc);
	while(tc--){
		scanf("%s",s);
		n = strlen(s);
		int a = -1, b = -1;
		for(int i=0; i<n; ++i){
			if(s[i] == 'P' && a == -1){
				a = i;
			}
			if(s[i] == 'P' && a != -1){
				b = i;
			}
		}
		int c = 1;
		for(int j=0; j<4; ++j) c &= winner(a, b, j);
		printf("%d\n", 2 - c);
		memset(memo, -1, sizeof(memo));
	}
}

Test details

Test 1

Group: 1, 2

Verdict:

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

correct output
2
2
2
1
2
...

user output
2
2
2
1
2
...
Truncated

Test 2

Group: 2

Verdict:

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

correct output
2
1
2
1
1
...

user output
2
1
2
1
1
...
Truncated