이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
int k, n, m, o, x, y, z, i, j, cost[50010][5], ans[50010];
int main() {
cin.sync_with_stdio(false);
cin.tie(nullptr);
memset(cost, 63, sizeof cost);
cin >> k >> n >> m >> o;
while(m--) {
cin >> x >> y >> z;
cost[x][y%k] = z;
}
while(o--) {
cin >> x >> y;
for(i = x; i <= y; ++i) ans[i] = 1e9; ans[x] = 0;
for(i = x; i < y/k*k; i++) for(j = 0; j < k; j++)
ans[i/k*k+k+j] = min(ans[i] + cost[i][j], ans[i/k*k+k+j]);
cout << (ans[y]==1e9?-1:ans[y]) << '\n';
}
}
컴파일 시 표준 에러 (stderr) 메시지
toll.cpp: In function 'int main()':
toll.cpp:15:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
15 | for(i = x; i <= y; ++i) ans[i] = 1e9; ans[x] = 0;
| ^~~
toll.cpp:15:47: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
15 | for(i = x; i <= y; ++i) ans[i] = 1e9; ans[x] = 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |