Submission #492287

#TimeUsernameProblemLanguageResultExecution timeMemory
492287ValiAntonieThe Potion of Great Power (CEOI20_potion)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; struct querry{ int prim,doi,zi,indice; }r[50005]; bool cmp(querry A, querry B){ return A.zi < B.zi; } int n,d,u,q,alt[100005],i,j,i2,j2,result,f[50005]; pair <int,int> rel[200005]; set <int> s[10000000]; set<int>::iterator itr; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin>>n>>d>>u>>q; for(i=0;i<n;i++){ cin>>alt[i]; } for(i=1;i<=u;i++){ cin>>rel[i].first>>rel[i].second; } for(i=1;i<=q;i++){ cin>>r[i].prim>>r[i].doi>>r[i].zi; r[i].indice = i; } sort(r+1,r+q+1,cmp); for(i=1;i<=q;i++){ for(j=r[i-1].zi+1;j<=r[i].zi;j++){ if(s[rel[j].first].count(alt[rel[j].second]) == 0){ s[rel[j].first].insert(alt[rel[j].second]); } else{ s[rel[j].first].erase(alt[rel[j].second]); } if(s[rel[j].second].count(alt[rel[j].first]) == 0){ s[rel[j].second].insert(alt[rel[j].first]); } else{ s[rel[j].second].erase(alt[rel[j].first]); } } vector<int> a(s[r[i].prim].begin(), s[r[i].prim].end()); vector<int> b(s[r[i].doi].begin(), s[r[i].doi].end()); result = 1000000000; i2 = 0; j2 = 0; while(i2 < a.size() && j2 < b.size()){ if(abs(a[i2] - b[j2]) < result) result = abs(a[i2] - b[j2]); if(a[i2] < a[j2]) i2++; else j2++; } f[r[i].indice] = result; } for(i=1;i<=q;i++){ cout << f[i] << '\n'; cout.flush(); } return 0; }

Compilation message (stderr)

potion.cpp: In function 'int main()':
potion.cpp:54:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |     while(i2 < a.size() && j2 < b.size()){
      |           ~~~^~~~~~~~~~
potion.cpp:54:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |     while(i2 < a.size() && j2 < b.size()){
      |                            ~~~^~~~~~~~~~
/usr/bin/ld: /tmp/ccCGVCxE.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccdHSJSB.o:potion.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccCGVCxE.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*)'
/usr/bin/ld: grader.cpp:(.text.startup+0x1d9): undefined reference to `question(int, int, int)'
collect2: error: ld returned 1 exit status