Submission #853816

#TimeUsernameProblemLanguageResultExecution timeMemory
853816kthngCrocodile's Underground City (IOI11_crocodile)C++17
Compilation error
0 ms0 KiB
#include<iostream> #include<algorithm> #include<vector> using namespace std; typedef pair<int, int> pii; vector<pii> a[100001]; int d[100001]; int n, m, k; int inf = 1e9 + 100; int f(int x) { if (d[x] != -1) return d[x]; d[x] = inf; vector<pii> tmp; for (int i = 0; i < a[x].size(); i++) { tmp.push_back(pii(f(a[x][i].first) + a[x][i].second, a[x][i].first)); } sort(tmp.begin(), tmp.end()); if (a[x].size() != 1) d[x] = min(d[x], tmp[1].first); return d[x]; } int main() { scanf("%d%d%d", &n, &m, &k); for (int i = 0; i < m; i++) { int t0, t1, t2; scanf("%d%d%d", &t0, &t1, &t2); a[t0].push_back(pii(t1, t2)); a[t1].push_back(pii(t0, t2)); } for (int i = 0; i < n; i++) d[i] = -1; for (int i = 0; i < k; i++) { int t0; scanf("%d", &t0); d[t0] = 0; } printf("%d\n", f(0)); return 0; }

Compilation message (stderr)

crocodile.cpp: In function 'int f(int)':
crocodile.cpp:17:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |  for (int i = 0; i < a[x].size(); i++) {
      |                  ~~^~~~~~~~~~~~~
crocodile.cpp: In function 'int main()':
crocodile.cpp:27:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |  scanf("%d%d%d", &n, &m, &k);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~
crocodile.cpp:30:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |   scanf("%d%d%d", &t0, &t1, &t2);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
crocodile.cpp:37:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |   scanf("%d", &t0);
      |   ~~~~~^~~~~~~~~~~
/usr/bin/ld: /tmp/ccoMB2fI.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccqnzXKF.o:crocodile.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccoMB2fI.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