Submission #396400


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define loop for(;;)
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;
#define inf (1e9)
#define eps (1e-9)
using Integer = long long;
using Real = long double;
const Real PI = acos(-1);

template<class S, class T> inline
ostream& operator<<(ostream&os, pair<S,T> p) {
  os << '(' << p.first << ", " << p.second << ')';
  return os;
}

template<class T> inline
ostream& operator<<(ostream&os, vector<T> v) {
  if (v.size() == 0) {
    os << "(empty)";
    return os;
  }
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

template<class T> inline
istream& operator>>(istream&is, vector<T>&v) {
  rep (i, v.size()) is >> v[i];
  return is;
}

int dx[] = { 1, 0, 1 };
int dy[] = { 0, 1, 1 };

using vi = vector<char>;
using vvi = vector<vi>;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout.setf(ios::fixed);
  cout.precision(10);

  int h, w; cin >> h >> w;
  ++h; ++w;

  vector<vector<bool>> f(h, vector<bool>(w, false));
  rep (i, h-1) {
    string s; cin >> s;
    rep (j, w-1) {
      if (s[j] == '#') f[i][j] = true;
    }
    f[i][w-1] = true;
  }
  rep (j, w) f[h-1][j] = true;

  vector<vector<bool>> bl(h, vector<bool>(w, false));
  rep (i, h-1) bl[i][w-1] = true;
  rep (j, w) bl[h-1][j] = true;

  for (int i = h-2; i >= 0; --i) {
    for (int j = w-2; j >= 0; --j) {
      bl[i][j] = false;
      rep (k, 3) {
        int i2 = i + dx[k];
        int j2 = j + dy[k];
        if (f[i2][j2]) continue;
        if (bl[i2][j2] == false) bl[i][j] = true;
      }
    }
  }

  // rep (i, h) { rep (j, w) cerr << bl[i][j]; cerr << endl; }
  cout << (bl[0][0] ? "First" : "Second") << endl;


  return 0;
}

Submission Info

Submission Time
Task B - マス目と駒
User cympfh
Language C++11 (GCC 4.9.2)
Score 100
Code Size 1837 Byte
Status
Exec Time 33 ms
Memory 928 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample-01.txt, sample-02.txt, sample-03.txt
Dataset1 30 / 30 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
Dataset2 70 / 70 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
Case Name Status Exec Time Memory
01-01.txt 25 ms 816 KB
01-02.txt 24 ms 928 KB
01-03.txt 26 ms 800 KB
01-04.txt 26 ms 804 KB
01-05.txt 25 ms 800 KB
01-06.txt 26 ms 804 KB
01-07.txt 26 ms 800 KB
01-08.txt 25 ms 928 KB
01-09.txt 26 ms 796 KB
01-10.txt 26 ms 804 KB
01-11.txt 32 ms 924 KB
01-12.txt 26 ms 804 KB
01-13.txt 26 ms 812 KB
01-14.txt 28 ms 800 KB
01-15.txt 33 ms 804 KB
02-01.txt 25 ms 928 KB
02-02.txt 26 ms 804 KB
02-03.txt 25 ms 800 KB
02-04.txt 26 ms 800 KB
02-05.txt 25 ms 736 KB
02-06.txt 26 ms 808 KB
02-07.txt 26 ms 796 KB
02-08.txt 26 ms 920 KB
02-09.txt 25 ms 796 KB
02-10.txt 30 ms 920 KB
02-11.txt 32 ms 920 KB
02-12.txt 25 ms 924 KB
02-13.txt 30 ms 800 KB
02-14.txt 26 ms 800 KB
02-15.txt 26 ms 800 KB
sample-01.txt 26 ms 792 KB
sample-02.txt 26 ms 804 KB
sample-03.txt 25 ms 928 KB