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

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:26:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&tc);
  ~~~~~^~~~~~~~~~
input/code.cpp:28: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][5];
int Rec(int a, int b, int c){
if(memo[a][b][c] != -1) return memo[a][b][c];
int &r = memo[a][b][c];
r = 1;
if(a - 1 >= 0 && c != 0 && !Rec(a-1, b, 1)) return r;
if(a + 1 < b && c != 1 && !Rec(a+1, b, 0)) return r;
if(a < b - 1 && c != 2 && !Rec(a, b-1, 3)) return r;
if(b + 1 < n && c != 3 && !Rec(a, b+1, 2)) return r;
return r = 0;
}
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'){
if(a == -1) a = i;
else b = i;
}
}
printf("%d\n", 2 - Rec(a, b, 4));
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: ACCEPTED

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

correct output
2
1
2
1
1
...

user output
2
1
2
1
1
...
Truncated