제출 #649779

#제출 시각아이디문제언어결과실행 시간메모리
649779mychecksedadRobot (JOI21_ho_t4)C++17
0 / 100
726 ms165396 KiB
/* Author : Mychecksdead */ #include<bits/stdc++.h> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; typedef long long int ll; typedef long double ld; #define MOD (1000000000+7) #define MOD1 (998244353) #define PI 3.1415926535 #define pb push_back #define setp() cout << setprecision(15) #define all(x) x.begin(), x.end() #define debug(x) cerr << #x << " is " << x << '\n'; const int N = 1e6+100, M = 1e5+10, F = 2147483646, K = 20; struct Edge{ int nxt, c, e; }; int n, m; ll dist[N]; vector<Edge> g[N]; multiset<int> color[N]; map<int, ll> s[N]; void solve(){ cin >> n >> m; for(int i = 0; i < m; ++i){ int u, v, c, p; cin >> u >> v >> c >> p; g[u].pb({v, c, p}); g[v].pb({u, c, p}); color[u].insert(c); color[v].insert(c); s[u][c] += p; s[v][c] += p; } for(int i = 1; i <= n; ++i) dist[i] = 1e18; priority_queue<array<ll, 3>> q; vector<bool> vis(n + 1); dist[n] = 0; q.push({0, n, -1}); while(!q.empty()){ int v = q.top()[1], cc = q.top()[2]; q.pop(); if(vis[v]) continue; vis[v] = 1; // cout << v << '\n'; for(auto E: g[v]){ int u = E.nxt, c = E.c; ll e = E.e; bool ok = 0; ll val = s[u][c]; if(cc == c) e = 0; if(e > val - e) ok = 1, e = val - e; if(dist[v] + e < dist[u]){ dist[u] = dist[v] + e; q.push({-dist[u], u, ok ? c : -1}); } } } if(dist[1] == 1e18) cout << -1; else cout << dist[1]; } int main(){ cin.tie(0); ios::sync_with_stdio(0); int T = 1, aa; // cin >> T;aa=T; while(T--){ // cout << "Case #" << aa-T << ": "; solve(); cout << '\n'; } return 0; }

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

Main.cpp: In function 'int main()':
Main.cpp:73:16: warning: unused variable 'aa' [-Wunused-variable]
   73 |     int T = 1, aa;
      |                ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...