제출 #1112261

#제출 시각아이디문제언어결과실행 시간메모리
1112261polarityRobot (JOI21_ho_t4)C++17
0 / 100
89 ms11212 KiB
/** * Solution by 1egend (polarity.sh) * Date: 2024-11-13 * Contest: CSES Problemset - Graph Algorithms * Problem: 1202 **/ #include <bits/stdc++.h> using namespace std; #define pb push_back #define ull unsigned long long #define ll long long const int MAX_N = 1e5 + 1; const ll MOD = 1e9 + 7; void solve(){ int n, m; cin >> n >> m; vector<ll> dist(n, 1e15); map<pair<int, int>, int> multiple; vector<vector<tuple<int, int, ll>>> adj(n); for (int i = 0; i < m; i++){ int a, b, c; cin >> a >> b >> c; --a; --b; --c; ll d; cin >> d; multiple[{a, c}]++; multiple[{b, c}]++; adj[a].pb({b, c, d}); adj[b].pb({a, c, d}); } using T = tuple<ll, int, int>; priority_queue<T, vector<T>, greater<T>> pq; dist[0] = 0; pq.push({0LL, 0, -1}); while(!pq.empty()){ auto [ndist, k, c] = pq.top(); pq.pop(); if (ndist != dist[k]) { continue; } for (tuple<int, int, ll> &node: adj[k]){ int kk = get<0>(node); int color = get<1>(node); ll cost = get<2>(node); if (multiple[{k, color}] == 1 || multiple[{k, color}] == 2 && c == color){ cost = 0; } if (ndist + cost < dist[kk]){ dist[kk] = ndist + cost; pq.push({dist[kk], kk, color}); } } } cout << (dist[n - 1] == 1e15 ? -1: dist[n - 1])<< endl; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); solve(); return 0; }

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

Main.cpp: In function 'void solve()':
Main.cpp:52:72: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   52 |             if (multiple[{k, color}] == 1 || multiple[{k, color}] == 2 && c == color){
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...