# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
197051 | Vlatko | Mobitel (COCI19_mobitel) | C++14 | 6096 ms | 1460 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
inline void add_self(int& x, int y) {
x += y;
if (x >= mod) x -= mod;
}
const int M = 310;
int R, C, N, ans;
int grid[M][M];
int ways[M][M]; // # paths to (R, C)
void dfs(int r, int c, ll prod) {
prod *= grid[r][c];
if (prod >= N) {
add_self(ans, ways[r][c]);
} else {
if (r < R) dfs(r+1, c, prod);
if (c < C) dfs(r, c+1, prod);
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> R >> C >> N;
for (int r = 1; r <= R; ++r) {
for (int c = 1; c <= C; ++c) {
cin >> grid[r][c];
}
}
for (int r = R; r >= 1; --r) {
for (int c = C; c >= 1; --c) {
ways[r][c] = (r == R && c == C);
if (r < R) add_self(ways[r][c], ways[r+1][c]);
if (c < C) add_self(ways[r][c], ways[r][c+1]);
}
}
ans = 0;
dfs(1, 1, 1);
cout << ans << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |