Submission #526792

#TimeUsernameProblemLanguageResultExecution timeMemory
526792zhangjishenCrocodile's Underground City (IOI11_crocodile)C++98
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define mp make_pair #define pb push_back #define fi first #define se second template<typename T> bool chkmin(T &a, T b){return b < a ? a = b, 1 : 0;} template<typename T> bool chkmax(T &a, T b){return b > a ? a = b, 1 : 0;} typedef long long ll; typedef pair<int, int> pii; const int MAXN = 1e5 + 10, inf = 2e9, MAXM = 1e6 + 10; int n, m, k, ext[MAXN], a[MAXM], b[MAXM], c[MAXM]; int g[MAXN], f[MAXN]; vector<pii> adj[MAXN]; priority_queue<pii, vector<pii>, greater<pii> > q; void dijkstra(){ for(int i = 1; i <= n; i++) g[i] = f[i] = inf; for(int i = 1; i <= k; i++){ int u = ext[i]; g[u] = f[u] = 0; q.push(mp(0, u)); } while(!q.empty()){ pii p = q.top(); q.pop(); int u = p.se; if(p.fi != f[u]) continue; for(int i = 0; i < (int)adj[u].size(); i++){ int v = adj[u][i].fi, w = adj[u][i].se; if(f[u] + w < g[v]){ f[v] = g[v]; if(f[v] != inf) q.push(mp(f[v], v)); g[v] = f[u] + w; }else if(chkmin(f[v], f[u] + w)) q.push(mp(f[v], v)); } } } int main(){ // input scanf("%d %d %d", &n, &m, &k); for(int i = 1; i <= m; i++){ scanf("%d %d", &a[i], &b[i]); a[i]++; b[i]++; } for(int i = 1; i <= m; i++){ scanf("%d", &c[i]); adj[a[i]].pb(mp(b[i], c[i])); adj[b[i]].pb(mp(a[i], c[i])); } for(int i = 1; i <= k; i++){ scanf("%d", &ext[i]); ext[i]++; } // dijkstra dijkstra(); printf("%d\n", f[1]); }

Compilation message (stderr)

crocodile.cpp: In function 'int main()':
crocodile.cpp:45:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   45 |  scanf("%d %d %d", &n, &m, &k);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
crocodile.cpp:47:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |   scanf("%d %d", &a[i], &b[i]);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
crocodile.cpp:51:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   51 |   scanf("%d", &c[i]);
      |   ~~~~~^~~~~~~~~~~~~
crocodile.cpp:56:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   56 |   scanf("%d", &ext[i]);
      |   ~~~~~^~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/cczfAEGD.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccZZaJqA.o:crocodile.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/cczfAEGD.o: in function `main':
grader.cpp:(.text.startup+0x36): undefined reference to `travel_plan(int, int, int (*) [2], int*, int, int*)'
collect2: error: ld returned 1 exit status