Submission #858000

#TimeUsernameProblemLanguageResultExecution timeMemory
858000sofijavelkovskaThe Potion of Great Power (CEOI20_potion)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int INF=1e9; int n, d, u; vector<int> h, a, b; void init(int N, int D, vector<int> H) { n=N; d=D; h=H; return; } void curseChanges(int U, vector<int> A, vector<int> B) { u=U; a=A; b=B; return; } int question(int x, int y, int v) { set<int> xtrust, ytrust; for (int i=0; i<v; i++) { if (a[i]==x) { if (!xtrust.count(b[i])) xtrust.insert(b[i]); else xtrust.erase(b[i]); } if (b[i]==x) { if (!xtrust.count(a[i])) xtrust.insert(a[i]); else xtrust.erase(a[i]); } if (a[i]==y) { if (!ytrust.count(b[i])) ytrust.insert(b[i]); else ytrust.erase(b[i]); } if (b[i]==y) { if (!ytrust.count(a[i])) ytrust.insert(a[i]); else ytrust.erase(a[i]); } } vector<int> vx, vy; for (auto t : xtrust) vx.push_back(h[t]); for (auto t : ytrust) vy.push_back(h[t]); sort(vx.begin(), vx.end()); sort(vy.begin(), vy.end()); if (vx.empty() || vy.empty()) return INF; int mind=INF; int j=0; for (int i=0; i<vx.size(); i++) { while (j<vy.size() && vx[i]>vy[j]) j=j+1; if (j<vy.size()) mind=min(mind, vy[j]-vx[i]); if (j-1>=0) mind=min(mind, vx[i]-vy[j-1]); } return mind; } /*int main() { init(6, 5, { 2 , 42 , 1000 , 54 , 68 , 234 } ); curseChanges(11, { 0 , 2 , 3 , 3 , 3 , 1 , 5 , 0 , 3 , 1 , 3 } , { 1 , 0 , 4 , 5 , 5 , 3 , 3 , 5 , 0 , 3 , 5 } ) ; while (true) { int x, y, v; cin >> x >> y >> v; cout << question(x, y, v) << '\n'; } return 0; }*/

Compilation message (stderr)

potion.cpp: In function 'int question(int, int, int)':
potion.cpp:72:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |     for (int i=0; i<vx.size(); i++)
      |                   ~^~~~~~~~~~
potion.cpp:74:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   74 |         while (j<vy.size() && vx[i]>vy[j])
      |                ~^~~~~~~~~~
potion.cpp:76:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   76 |         if (j<vy.size())
      |             ~^~~~~~~~~~
/usr/bin/ld: /tmp/ccaoZiUx.o: in function `main':
grader.cpp:(.text.startup+0xec): undefined reference to `init(int, int, int*)'
/usr/bin/ld: grader.cpp:(.text.startup+0x184): undefined reference to `curseChanges(int, int*, int*)'
collect2: error: ld returned 1 exit status