# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
425455 | errorgorn | Journey (NOI18_journey) | C++17 | 208 ms | 8908 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cstdio>
#include <vector>
#include <utility>
using namespace std;
typedef pair<int,int> ii;
int n,m,h;
vector<ii> flight[100005];
int memo[405][100005];
inline int add(int i,int j){
return min(i+j,500000001);
}
void print(){
for (int x=0;x<m;x++){
for (int y=0;y<n;y++){
printf("%d ",memo[y][x]);
}
printf("\n");
}
}
int main(){
scanf("%d%d%d",&n,&m,&h);
int a,b;
for (int x=0;x<n-1;x++){
for (int y=0;y<h;y++){
scanf("%d%d",&a,&b);
if (a<=x) continue;
flight[x].push_back(ii(a,b));
}
}
memo[0][0]=1;
memo[1][0]=-1;
for (int x=0;x<=m;x++){
for (int y=0;y<n;y++){
for (ii it:flight[y]){
if (it.second+x>m) continue;
memo[it.second+x][it.first]=add(memo[it.second+x][it.first],memo[x][y]);
}
memo[x+1][y]=add(memo[x+1][y],memo[x][y]);
}
}
for (int x=0;x<m;x++){
printf("%d ",memo[x][n-1]);
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |