제출 #1122389

#제출 시각아이디문제언어결과실행 시간메모리
1122389qrnAutobus (COCI22_autobus)C++14
0 / 70
1059 ms2128 KiB
#include <bits/stdc++.h> using namespace std; #define SPEED \ ios_base::sync_with_stdio(0); \ cin.tie(NULL); \ cout.tie(NULL); #define pb push_back #define endl "\n" #define ALL(x) x.begin(), x.end() #define intt long long const intt mxN = 2e5 + 5, L = 20, mxA = 1e6 + 35; struct edge{ intt l, r; }; vector<vector<intt>>graph; vector<intt>visited(mxN); vector<intt>path; map<pair<intt,intt>,intt>vals; intt ans = mxA; void dfs(intt u, intt end, intt k) { visited[u] = true; path.pb(u); if (u == end) { if(path.size()-1 <= k) { intt sum = 0; for(int i = 1; i < path.size(); i++) { // cout << path[i] << " "; sum += vals[{path[i-1], path[i]}]; } ans = min(ans, sum); // cout << endl; } else { // for(auto u : path) cout << u << " "; // cout << endl; } } else { for (auto v : graph[u]) { if (!visited[v]) { dfs(v, end, k); } } } path.pop_back(); visited[u] = false; } void solve() { intt n, m; cin >> n >> m; graph.resize(n + 1); for(intt i = 1; i <= m; i++) { intt a, b, w; cin >> a >> b >> w; graph[a].pb(b); vals[{a,b}] = w; } intt k, q; cin >> k >> q; while(q--) { intt l, r; cin >> l >> r; dfs(l, r, k); if(ans == mxA) cout << -1 << endl; else cout << ans << endl; ans = mxA; } } int main() { SPEED; int tst = 1; // cin >> tst; while (tst--) { solve(); } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'void dfs(long long int, long long int, long long int)':
Main.cpp:31:26: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   31 |         if(path.size()-1 <= k) {
      |            ~~~~~~~~~~~~~~^~~~
Main.cpp:33:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |             for(int i = 1; i < path.size(); i++) {
      |                            ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...