Submission #798761

#TimeUsernameProblemLanguageResultExecution timeMemory
798761PoonYaPatThe Potion of Great Power (CEOI20_potion)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "grader.cpp" using namespace std; typedef pair<int,vector<int>> piv; typedef pair<int,int> pii; int n,h[100005]; const int sq=300; vector<pii> c[100005]; vector<piv> v[100005]; bool comp(int a, int b) {return h[a]<h[b];} void init(int N, int D, int H[]) { n=N; for (int i=0; i<n; ++i) h[i]=H[i], v[i].push_back(piv(0,{})); } void curseChanges(int U, int A[], int B[]) { for (int i=0; i<U; ++i) { c[A[i]].push_back(pii(i+1,B[i])); c[B[i]].push_back(pii(i+1,A[i])); } for (int i=0; i<n; ++i) { vector<int> temp,temp2; v[i].push_back(piv(0,{})); for (int j=0; j<c[i].size(); ++j) { int add=c[i][j].second; bool have=false; for (auto s : temp) if (s==add) have=true; if (have) { for (auto s : temp) if (s!=add) temp2.push_back(s); } else { bool f=false; for (auto s : temp) { if (h[s]<h[add]) temp2.push_back(s); else { if (!f) { temp2.push_back(add); temp2.push_back(s); } else temp2.push_back(s); } } if (!f) temp2.push_back(add); } swap(temp,temp2); temp2.clear(); if ((j+1)%sq==0) v[i].push_back(piv(c[i][j].first,temp)); } } } int question(int x, int y, int day) { int hx=upper_bound(v[x].begin(),v[x].end(),piv(day+1,{}))-v[x].begin()-1; int hy=upper_bound(v[y].begin(),v[y].end(),piv(day+1,{}))-v[y].begin()-1; vector<int> tempx=v[x][hx].second,tempy=v[y][hy].second; map<int,int> haveX,haveY; for (auto s : tempx) haveX[s]++; for (auto s : tempy) haveY[s]++; int Hx=upper_bound(c[x].begin(),c[x].end(),pii(v[x][hx].first,INT_MAX))-c[x].begin(); while (Hx<c[x].size() && c[x][Hx].first<=day) tempx.push_back(c[x][Hx].second), ++haveX[c[x][Hx].second], ++Hx; int Hy=upper_bound(c[y].begin(),c[y].end(),pii(v[y][hy].first,INT_MAX))-c[y].begin(); while (Hy<c[y].size() && c[y][Hy].first<=day) tempy.push_back(c[y][Hy].second), ++haveY[c[y][Hy].second], ++Hy; sort(tempx.begin(),tempx.end(),comp); sort(tempy.begin(),tempy.end(),comp); int xi=0, yi=0, nx=tempx.size(), ny=tempy.size(); int ans=1e9; while (xi<nx && yi<ny) { if (haveX[tempx[xi]]%2==0) ++xi; else if (haveY[tempy[yi]]%2==0) ++yi; else { ans=min(ans,abs(h[tempx[xi]]-h[tempy[yi]])); if (h[tempx[xi]]>h[tempy[yi]]) ++yi; else ++xi; } } return ans; }

Compilation message (stderr)

potion.cpp: In function 'void curseChanges(int, int*, int*)':
potion.cpp:28:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |         for (int j=0; j<c[i].size(); ++j) {
      |                       ~^~~~~~~~~~~~
potion.cpp: In function 'int question(int, int, int)':
potion.cpp:66:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |     while (Hx<c[x].size() && c[x][Hx].first<=day) tempx.push_back(c[x][Hx].second), ++haveX[c[x][Hx].second], ++Hx;
      |            ~~^~~~~~~~~~~~
potion.cpp:69:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |     while (Hy<c[y].size() && c[y][Hy].first<=day) tempy.push_back(c[y][Hy].second), ++haveY[c[y][Hy].second], ++Hy;
      |            ~~^~~~~~~~~~~~
/usr/bin/ld: /tmp/ccL9PWnq.o: in function `sigH(int)':
grader.cpp:(.text+0x0): multiple definition of `sigH(int)'; /tmp/cc5rktat.o:potion.cpp:(.text+0x20): first defined here
/usr/bin/ld: /tmp/ccL9PWnq.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc5rktat.o:potion.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status