이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long ll;
typedef long double ld;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n,m,h;
cin >> n >> m >> h;
vector <vector <pair<ll,ll>>> arr(n);
for (int z=0;z<n-1;z++){
for (int x=0;x<h;x++){
ll a,b;
cin >> a >> b;
arr[z].push_back(make_pair(a,b));
}
}
vector <vector<ll>> dp(n,vector<ll>(m,0));
for (int x=0;x<h;x++){
dp[arr[0][x].first][arr[0][x].second]++;
}
ll temp = 0;
for (int z=1;z<n-1;z++){
for (int y=0;y<m;y++){
if (dp[z][y] == 0) continue;
for (int x=0;x<h;x++){
if (y+arr[z][x].second >= m) continue;
if (arr[z][x].first <= z) continue;
dp[arr[z][x].first][y+arr[z][x].second]+= dp[z][y];
dp[arr[z][x].first][y+arr[z][x].second] = min(dp[arr[z][x].first][y+arr[z][x].second],ll(500000001));
}
if (y < m-1) dp[z][y+1] += dp[z][y];
dp[z][y] = min(dp[z][y],ll(500000001));
dp[z][y+1] = min(dp[z][y+1],ll(500000001));
}
temp = 0;
}
ll c = 0;
for (int z=0;z<m;z++){
cout << min(c+dp[n-1][z],ll(500000001)) << " ";
c += dp[n-1][z];
} cout << endl;
}
컴파일 시 표준 에러 (stderr) 메시지
journey.cpp: In function 'int main()':
journey.cpp:34:5: warning: variable 'temp' set but not used [-Wunused-but-set-variable]
ll temp = 0;
^~~~| # | 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... |