Submission #1178339
Source Code Expand
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif
#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
int H, W; cin >> H >> W;
vector<vector<int>>a(H, vector<int>(W));
rep(i, 0, H)rep(j, 0, W)cin >> a[i][j];
auto within = [&](int x, int y) {return 0 <= x&&x < H && 0 <= y&&y < W; };
int dx[]{ 1,0,-1,0 }, dy[]{ 0,1,0,-1 };
vector<vector<int>>dp(H, vector<int>(W, 0));
function<int(int,int)> dfs = [&](int x, int y) {
if (dp[x][y] != 0)return dp[x][y];
int ret(1);
rep(k, 0, 4) {
int X = x + dx[k], Y = y + dy[k];
if (within(X, Y) && a[x][y] < a[X][Y])ret += dfs(X, Y) % MOD;
}
return dp[x][y] = ret;
};
int ans(0);
rep(i, 0, H)rep(j, 0, W)ans += dfs(i, j) % MOD;
cout << ans << endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
D - 経路 |
User |
norma |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
1309 Byte |
Status |
WA |
Exec Time |
157 ms |
Memory |
16128 KB |
Judge Result
Set Name |
sample |
All |
Score / Max Score |
0 / 0 |
0 / 100 |
Status |
|
|
Set Name |
Test Cases |
sample |
sample01.txt, sample02.txt |
All |
00.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, sample01.txt, sample02.txt, sample01.txt, sample02.txt |
Case Name |
Status |
Exec Time |
Memory |
00.txt |
WA |
105 ms |
16128 KB |
01.txt |
WA |
119 ms |
16128 KB |
02.txt |
AC |
91 ms |
15872 KB |
03.txt |
AC |
1 ms |
256 KB |
04.txt |
AC |
1 ms |
256 KB |
05.txt |
AC |
1 ms |
256 KB |
06.txt |
AC |
1 ms |
256 KB |
07.txt |
AC |
1 ms |
256 KB |
08.txt |
AC |
1 ms |
256 KB |
09.txt |
AC |
1 ms |
256 KB |
10.txt |
AC |
2 ms |
256 KB |
11.txt |
AC |
156 ms |
16000 KB |
12.txt |
AC |
156 ms |
16000 KB |
13.txt |
AC |
155 ms |
16000 KB |
14.txt |
AC |
157 ms |
16000 KB |
15.txt |
WA |
133 ms |
16128 KB |
16.txt |
AC |
155 ms |
16000 KB |
17.txt |
AC |
156 ms |
16000 KB |
18.txt |
AC |
98 ms |
16000 KB |
19.txt |
AC |
80 ms |
16000 KB |
sample01.txt |
AC |
1 ms |
256 KB |
sample02.txt |
AC |
1 ms |
256 KB |