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 <bits/stdc++.h>
#define ff(j, a, b) for(long long j=a;j<b;j++)
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<ll> vll;
ll n, m, h;
vpll* planes;
vll* dp;
ll MAX=500000001;
int main()
{
cin >> n >> m >> h;
planes = new vpll[n];
dp = new vll[n];
ff(j, 0, m)
{
dp[0].pb(0);
}
ff(j, 1, n)
{
dp[j]=dp[0];
}
ff(j, 0, n-1)
{
ff(k, 0, h)
{
ll dest, wait;
cin >> dest >> wait;
if(dest<j)
{
continue;
}
planes[j].pb( pll(dest, wait) );
}
}
dp[0][0]=1;
ff(j, 0, n-1)
{
ff(k, 1, m)
{
dp[j][k] += dp[j][k-1];
dp[j][k] = min(dp[j][k], MAX);
}
ff(p, 0, planes[j].size())
{
ll dest=planes[j][p].first, wait=planes[j][p].second;
ff(t, 0, m-wait)
{
dp[dest][wait+t] += dp[j][t];
dp[dest][wait+t] = min(MAX, dp[dest][wait+t]);
}
}
}
cout << dp[n-1][0];
ff(j, 1, m)
{
cout << " " << dp[n-1][j];
}
return 0;
}
Compilation message (stderr)
journey.cpp: In function 'int main()':
journey.cpp:2:40: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
#define ff(j, a, b) for(long long j=a;j<b;j++)
journey.cpp:54:12:
ff(p, 0, planes[j].size())
~~~~~~~~~~~~~~~~~~~~~~
journey.cpp:54:9: note: in expansion of macro 'ff'
ff(p, 0, planes[j].size())
^~
# | 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... |