| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 698514 | Gital | Autobus (COCI22_autobus) | C++11 | 100 ms | 356 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;
ll dp[75];
vector<pair<ll,ll>> v[75];
bool checked[75];
int n,m;
priority_queue<pair<pair<ll,ll>,ll>,vector<pair<pair<ll,ll>,ll>>,greater<pair<pair<ll,ll>,ll>>> pq;
int k,q;
int main () {
ios::sync_with_stdio(0); cin.tie(0);
cin >> n >> m;
for(int i = 0; i < m; i++) {
ll a,b,c; cin >> a >> b >> c;
v[a].push_back({c,b});
}
cin >> k >> q;
for(int j = 0; j < q; j++) {
ll st,en; cin >> st >> en;
for(int i = 0; i < 75; i++) {
checked[i] = false;
dp[i] = -1;
}
dp[st] = 0;
pq.push({{0,st},0});
while(!pq.empty()) {
ll a = pq.top().first.first;
ll b = pq.top().first.second;
ll cnt = pq.top().second;
pq.pop();
/*if(checked[b]) continue;
checked[b] = true;*/
if(cnt >= k) continue;
for(int i = 0; i < v[b].size(); i++) {
if(dp[v[b][i].second] == -1 || dp[v[b][i].second] > a + v[b][i].first) {
dp[v[b][i].second] = max((ll)0,a + v[b][i].first);
pq.push({{dp[v[b][i].second],v[b][i].second},cnt+1});
}
}
}
cout << dp[en] << endl;
}
return 0;
}
컴파일 시 표준 에러 (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... | ||||
