Submission #3426964
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto x:v)cerr<<x<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define EPS 1e-9
typedef long long ll;
int H,W;
bool wall[101][101];
int DFS[101][101][2];
int dx[] = {1,1,0};
int dy[] = {0,1,1};
int dfs(int x,int y,int n){
if(DFS[x][y][n] != -1)return DFS[x][y][n];
if(wall[x+1][y] && wall[x+1][y+1] && wall[x][y+1])return DFS[x][y][n] = n;
vector<int> v;
FOR(i,0,3)if(!wall[x+dx[i]][y+dy[i]])v.pb(dfs(x+dx[i],y+dy[i],(n+1)%2));
sort(ALL(v));
if(n == 0){
return DFS[x][y][n] = v[v.size()-1];
}
else{
return DFS[x][y][n] = v[0];
}
}
signed main(){
cin >> H >> W;
char c;
FOR(i,0,101)FOR(j,0,101)FOR(k,0,2)DFS[i][j][k] = -1;
FOR(i,0,H)FOR(j,0,W){
cin >> c;
wall[i][j] = (c == '#');
}
FOR(i,0,H+1)wall[i][W] = 1;
FOR(j,0,W+1)wall[H][j] = 1;
if(dfs(0,0,0))cout << "First" << endl;
else cout << "Second" << endl;
}
Submission Info
Submission Time |
|
Task |
B - マス目と駒 |
User |
nu50218 |
Language |
C++14 (GCC 5.4.1) |
Score |
100 |
Code Size |
1324 Byte |
Status |
AC |
Exec Time |
4 ms |
Memory |
384 KB |
Judge Result
Set Name |
Sample |
Dataset1 |
Dataset2 |
Score / Max Score |
0 / 0 |
30 / 30 |
70 / 70 |
Status |
|
|
|
Set Name |
Test Cases |
Sample |
sample-01.txt, sample-02.txt, sample-03.txt |
Dataset1 |
sample-01.txt, sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt |
Dataset2 |
sample-01.txt, sample-02.txt, sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 02-01.txt, 02-02.txt, 02-03.txt, 02-04.txt, 02-05.txt, 02-06.txt, 02-07.txt, 02-08.txt, 02-09.txt, 02-10.txt, 02-11.txt, 02-12.txt, 02-13.txt, 02-14.txt, 02-15.txt, sample-01.txt, sample-02.txt, sample-03.txt |
Case Name |
Status |
Exec Time |
Memory |
01-01.txt |
AC |
1 ms |
384 KB |
01-02.txt |
AC |
1 ms |
384 KB |
01-03.txt |
AC |
1 ms |
384 KB |
01-04.txt |
AC |
1 ms |
384 KB |
01-05.txt |
AC |
1 ms |
384 KB |
01-06.txt |
AC |
1 ms |
384 KB |
01-07.txt |
AC |
1 ms |
384 KB |
01-08.txt |
AC |
1 ms |
384 KB |
01-09.txt |
AC |
1 ms |
384 KB |
01-10.txt |
AC |
1 ms |
384 KB |
01-11.txt |
AC |
1 ms |
384 KB |
01-12.txt |
AC |
1 ms |
384 KB |
01-13.txt |
AC |
1 ms |
384 KB |
01-14.txt |
AC |
1 ms |
384 KB |
01-15.txt |
AC |
1 ms |
384 KB |
02-01.txt |
AC |
4 ms |
384 KB |
02-02.txt |
AC |
1 ms |
384 KB |
02-03.txt |
AC |
2 ms |
384 KB |
02-04.txt |
AC |
1 ms |
384 KB |
02-05.txt |
AC |
1 ms |
384 KB |
02-06.txt |
AC |
4 ms |
384 KB |
02-07.txt |
AC |
4 ms |
384 KB |
02-08.txt |
AC |
4 ms |
384 KB |
02-09.txt |
AC |
3 ms |
384 KB |
02-10.txt |
AC |
3 ms |
384 KB |
02-11.txt |
AC |
3 ms |
384 KB |
02-12.txt |
AC |
2 ms |
384 KB |
02-13.txt |
AC |
2 ms |
384 KB |
02-14.txt |
AC |
2 ms |
384 KB |
02-15.txt |
AC |
2 ms |
384 KB |
sample-01.txt |
AC |
1 ms |
384 KB |
sample-02.txt |
AC |
1 ms |
384 KB |
sample-03.txt |
AC |
1 ms |
384 KB |