Submission #3947874
Source Code Expand
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
template<int MOD> struct ModInt {
static const int Mod = MOD; unsigned x; ModInt() : x(0) { }
ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
int get() const { return (int)x; }
ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
ModInt inverse() const { long long a = x, b = MOD, u = 1, v = 0;
while (b) { long long t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); }
return ModInt(u); }
bool operator==(ModInt that) const { return x == that.x; }
bool operator!=(ModInt that) const { return x != that.x; }
ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; }
};
template<int MOD> ostream& operator<<(ostream& st, const ModInt<MOD> a) { st << a.get(); return st; };
template<int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) {
ModInt<MOD> r = 1; while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r; }
typedef ModInt<1000000007> mint;
/*---------------------------------------------------------------------------------------------------
∧_∧
∧_∧ (´<_` ) Welcome to My Coding Space!
( ´_ゝ`) / ⌒i
/ \ | |
/ / ̄ ̄ ̄ ̄/ |
__(__ニつ/ _/ .| .|____
\/____/ (u ⊃
---------------------------------------------------------------------------------------------------*/
int H, W; string A[1010];
mint dp[1010][1010];
//---------------------------------------------------------------------------------------------------
void _main() {
cin >> H >> W;
rep(y, 0, H) cin >> A[y];
dp[0][0] = 1;
rep(y, 0, H) rep(x, 0, W) {
if (y + 1 < H and A[y + 1][x] != '#') dp[y + 1][x] += dp[y][x];
if (x + 1 < W and A[y][x + 1] != '#') dp[y][x + 1] += dp[y][x];
}
cout << dp[H - 1][W - 1] << endl;
}
Submission Info
| Submission Time | |
|---|---|
| Task | H - Grid 1 |
| User | hamayanhamayan |
| Language | C++14 (GCC 5.4.1) |
| Score | 100 |
| Code Size | 3401 Byte |
| Status | AC |
| Exec Time | 17 ms |
| Memory | 5248 KiB |
Judge Result
| Set Name | All | ||
|---|---|---|---|
| Score / Max Score | 100 / 100 | ||
| Status |
|
| Set Name | Test Cases |
|---|---|
| All | 0_00, 0_01, 0_02, 0_03, 1_00, 1_01, 1_02, 1_03, 1_04, 1_05, 1_06, 1_07, 1_08, 1_09, 1_10, 1_11 |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 0_00 | AC | 3 ms | 4224 KiB |
| 0_01 | AC | 3 ms | 4224 KiB |
| 0_02 | AC | 3 ms | 4224 KiB |
| 0_03 | AC | 3 ms | 4224 KiB |
| 1_00 | AC | 3 ms | 4224 KiB |
| 1_01 | AC | 3 ms | 4224 KiB |
| 1_02 | AC | 13 ms | 5248 KiB |
| 1_03 | AC | 8 ms | 5248 KiB |
| 1_04 | AC | 7 ms | 5248 KiB |
| 1_05 | AC | 17 ms | 5248 KiB |
| 1_06 | AC | 14 ms | 5248 KiB |
| 1_07 | AC | 13 ms | 5248 KiB |
| 1_08 | AC | 13 ms | 5248 KiB |
| 1_09 | AC | 13 ms | 5248 KiB |
| 1_10 | AC | 13 ms | 5248 KiB |
| 1_11 | AC | 13 ms | 5248 KiB |