| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 958703 | adaawf | 힘 센 거북 (IZhO11_turtle) | C++14 | 180 ms | 205180 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <queue>
using namespace std;
long long int f[1005][1005][21], dd[1005][1005], a[1005][1005];
int main() {
int n, m, k, t, z;
cin >> n >> m >> k >> t >> z;
for (int i = 1; i <= k; i++) {
int x, y;
cin >> x >> y;
a[x][y] = 1;
}
queue<pair<int, int>> q;
f[0][0][0] = 1;
q.push({0, 0});
while (!q.empty()) {
int x = q.front().first, y = q.front().second;
q.pop();
for (int i = 0; i <= t; i++) {
f[x + 1][y][i + a[x + 1][y]] += f[x][y][i];
f[x + 1][y][i + a[x + 1][y]] %= z;
f[x][y + 1][i + a[x][y + 1]] += f[x][y][i];
f[x][y + 1][i + a[x][y + 1]] %= z;
if (dd[x + 1][y] == 0 && x < n) {
q.push({x + 1, y});
dd[x + 1][y] = 1;
}
if (dd[x][y + 1] == 0 && y < m) {
q.push({x, y + 1});
dd[x][y + 1] = 1;
}
}
}
long long int res = 0;
for (int i = 0; i <= t; i++) res = (res + f[n][m][i]) % z;
cout << res;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
