제출 #388199

#제출 시각아이디문제언어결과실행 시간메모리
388199BartolMRobot (JOI21_ho_t4)C++17
24 / 100
2418 ms127304 KiB
#define DEBUG 1 #include <bits/stdc++.h> using namespace std; #define X first #define Y second #define mp make_pair #define pb push_back typedef long long ll; typedef pair <int, int> pii; typedef pair <int, pii> pip; typedef pair <pii, int> ppi; typedef pair <ll, ll> pll; typedef pair <int, ll> pil; typedef pair <ll, int> pli; const int INF=0x3f3f3f3f; const int N=8e5+5; const ll MAX=(ll)INF*INF; int n, m, uk; map <pii, int> boja, koji, zbr; ll dist[N]; vector <pil> ls[N]; set <pli> S; void dijkstra() { fill(dist, dist+N, MAX); dist[1]=0; S.insert(mp(0, 1)); while (!S.empty()) { pli node=*S.begin(); S.erase(S.begin()); for (pil sus:ls[node.Y]) { if (dist[sus.X]<=sus.Y+node.X) continue; if (S.count(mp(dist[sus.X], sus.X))) S.erase(mp(dist[sus.X], sus.X)); dist[sus.X]=node.X+sus.Y; S.insert(mp(dist[sus.X], sus.X)); } } } void solve() { uk=n+1; for (int i=1; i<=n; ++i) { for (int j=0; j<ls[i].size(); ++j) { pil sus=ls[i][j]; if (sus.X>n) continue; int boj=boja[{i, sus.X}]; if (!koji[{i, boj}]) { ls[i].pb(mp(uk, 0)); koji[{i, boj}]=uk++; } int node=koji[{i, boj}]; ls[sus.X].pb(mp(node, 0)); ls[node].pb(mp(sus.X, zbr[{i, boj}]-sus.Y)); assert( zbr[mp(i, boj)]>=sus.Y ); } } dijkstra(); printf("%lld\n", dist[n]>=MAX ? -1 : dist[n]); } void load() { scanf("%d %d", &n, &m); for (int i=0; i<m; ++i) { int a, b, boj, cos; scanf("%d %d %d %d", &a, &b, &boj, &cos); ls[a].pb(mp(b, cos)); ls[b].pb(mp(a, cos)); boja[{a, b}]=boj; boja[{b, a}]=boj; zbr[{a, boj}]+=cos; zbr[{b, boj}]+=cos; } } int main() { load(); solve(); return 0; }

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

Main.cpp: In function 'void solve()':
Main.cpp:47:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |         for (int j=0; j<ls[i].size(); ++j) {
      |                       ~^~~~~~~~~~~~~
Main.cpp: In function 'void load()':
Main.cpp:68:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   68 |     scanf("%d %d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~~
Main.cpp:71:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   71 |         scanf("%d %d %d %d", &a, &b, &boj, &cos);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...