| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 644626 | guagua0407 | Toll (BOI17_toll) | C++17 | 127 ms | 101520 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
void setIO(string s) {
freopen((s + ".in").c_str(), "r", stdin);
freopen((s + ".out").c_str(), "w", stdout);
}
const int mxn=5e4+5;
int dp[mxn][20][5][5];
int jump[mxn][20][5][5];
int ans[5][5];
int tmp[5][5];
int k,n,m,q;
void ckmin(int a[5][5],int b[5][5],int c[5][5]){
for(int i=0;i<k;i++){
for(int j=0;j<k;j++){
for(int z=0;z<k;z++){
a[i][z]=min(a[i][z],b[i][j]+c[j][z]);
}
}
}
}
int main() {_
//setIO("wayne");
cin>>k>>n>>m>>q;
memset(dp,0x3f,sizeof dp);
for(int i=0;i<m;i++){
int a,b,t;
cin>>a>>b>>t;
dp[a/k][0][a%k][b%k]=t;
}
for (int j = 1; j < 17; j++) {
for (int i = 0; i + (1 << j) < (n + k - 1) / k; i++) {
ckmin(dp[i][j], dp[i][j - 1], dp[i + (1 << j - 1)][j - 1]);
}
}
while (q--) {
int a, b;
cin >> a >> b;
memset(ans, 0x3f, sizeof ans);
for (int i = 0; i < 5; i++) ans[i][i] = 0;
for (int curr = a / k, dest = b / k, i = 16; ~i; i--) {
if (curr + (1 << i) <= dest) {
memset(tmp, 0x3f, sizeof tmp);
ckmin(tmp, ans, dp[curr][i]);
memcpy(ans, tmp, sizeof ans);
curr += (1 << i);
}
}
cout << (ans[a % k][b % k] == 0x3f3f3f3f ? -1 : ans[a % k][b % k]) << '\n';
}
return 0;
}
//maybe its multiset not set
컴파일 시 표준 에러 (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... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
