이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;
ll dp[75][75];
vector<pair<ll,ll>> v[75];
//bool checked[75];
int n,m;
priority_queue<pair<pair<ll,ll>,set<ll>>,vector<pair<pair<ll,ll>,set<ll>>>,greater<pair<pair<ll,ll>,set<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 i = 1; i <= n; i++) {
        for(int j = 0; j <= n; j++) {
            dp[i][j] = -1;
        }
        dp[i][i] = 0;
        set<ll> s;
        pq.push({{0,i},s});
        while(!pq.empty()) {
            ll a = pq.top().first.first;
            ll b = pq.top().first.second;
            set<ll> cnt = pq.top().second;
            pq.pop();
            if(cnt.count(b)) continue;
            cnt.insert(b);
            if(cnt.size() >= k + 1) continue;
            for(int j = 0; j < v[b].size(); j++) {
                if(dp[i][v[b][j].second] == -1) dp[i][v[b][j].second] = a + v[b][j].first;
                else dp[i][v[b][j].second] = min(dp[i][v[b][j].second],a + v[b][j].first);
                pq.push({{a + v[b][j].first,v[b][j].second},cnt});
            }
        }
    }
    for(int i = 0; i < q; i++) {
        int c,d; cin >> c >> d;
        cout << dp[c][d] << endl;
    }
    return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp: In function 'int main()':
Main.cpp:33:27: warning: comparison of integer expressions of different signedness: 'std::set<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   33 |             if(cnt.size() >= k + 1) continue;
      |                ~~~~~~~~~~~^~~~~~~~
Main.cpp:34:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |             for(int j = 0; j < v[b].size(); j++) {
      |                            ~~^~~~~~~~~~~~~| # | 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... |