제출 #72586

#제출 시각아이디문제언어결과실행 시간메모리
72586Bruteforceman악어의 지하 도시 (IOI11_crocodile)C++11
0 / 100
259 ms248340 KiB
#include <bits/stdc++.h> #include "crocodile.h" using namespace std; const long long inf = 1e15; struct data { int node; long long dist; data (int node, long long dist) { this -> node = node; this -> dist = dist; } data ( ) {} bool operator < (data x) const { return dist > x.dist; } }; vector <int> g[100010]; vector <int> c[100010]; long long d[100010][2]; bool vis[100010]; int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) { // freopen("in.txt", "r", stdin); int n, m, k; scanf("%d %d %d", &n, &m, &k); for(int i = 1; i <= m; i++) { int p, q, r; scanf("%d %d %d", &p, &q, &r); g[p].push_back(q); g[q].push_back(p); c[p].push_back(r); c[q].push_back(r); } for(int i = 0; i < n; i++) { d[i][0] = d[i][1] = inf; } priority_queue <data> Q; for(int i = 0; i < k; i++) { int x; scanf("%d", &x); d[x][1] = d[x][0] = 0; Q.push(data(x, 0)); } while(not Q.empty()) { data x = Q.top(); Q.pop(); int p = x.node; long long dist = x.dist; if(vis[p] == true) continue; vis[p] = true; for(unsigned i = 0; i < g[p].size(); i++) { long long cost = c[p][i] + dist; int q = g[p][i]; if(d[q][0] >= cost) { d[q][1] = d[q][0]; d[q][0] = cost; Q.push( data(q, d[q][1]) ); } else if (d[q][1] > cost) { d[q][1] = cost; Q.push( data(q, cost) ); } } } return d[0][1]; }

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

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:29:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d", &n, &m, &k);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
crocodile.cpp:32:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d %d", &p, &q, &r);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
crocodile.cpp:45:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &x);
         ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...