#include "bits/stdc++.h"
using namespace std;
#define int long long
#define fr first
#define sc second
#define eb emplace_back
#define nl '\n'
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cerr << "LINE(" << __LINE__ << ") -> " <<"[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
const int inf = 5e8L + 1;
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
int N, M, H;
cin >> N >> M >> H;
pair<int, int> adj[N][H];
for(int i = 0; i < N - 1; ++i) {
for(int j = 0; j < H; ++j) {
cin >> adj[i][j].fr >> adj[i][j].sc;
}
}
/* for(int i = 0; i < N - 1; ++i) { */
/* for(int j = 0; j < H; ++j) { */
/* cout << adj[i][j].fr << ' ' << adj[i][j].sc << ' '; */
/* } */
/* cout << nl; */
/* } */
int res[N][M] = {};
res[0][0] = 1;
for(int i = 0; i < N - 1; ++i) {
for(int j = 0; j < M; ++j) {
if(i != 0 && j != 0) res[i][j] += res[i][j - 1];
if(res[i][j] >= inf) res[i][j] = inf;
for(int k = 0; k < H; ++k) {
if(j + adj[i][k].sc < M) {
res[adj[i][k].fr][j + adj[i][k].sc] += res[i][j];
if(res[adj[i][k].fr][j + adj[i][k].sc] >= inf) res[adj[i][k].fr][j + adj[i][k].sc] = inf;
}
}
}
}
for(int i = 0; i < M; ++i) {
if(i != 0) res[N - 1][i] += res[N - 1][i - 1];
if(res[N - 1][i] >= inf) res[N - 1][i] = inf;
cout << res[N - 1][i] << ' ';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |