Submission #1043060

#TimeUsernameProblemLanguageResultExecution timeMemory
1043060beaconmcThe Potion of Great Power (CEOI20_potion)C++14
21 / 100
1588 ms95660 KiB
#include <bits/stdc++.h> typedef int ll; #define FOR(i,x,y) for(ll i=x; i<y; i++) #define FORNEG(i,x,y) for(ll i=x; i>y; i--) using namespace std; vector<set<ll>> edges[101]; vector<ll> h; vector<ll> a; vector<ll> b; void init(int N, int D, int H[]) { FOR(i,0,N) h.push_back(H[i]); } void curseChanges(int U, int A[], int B[]) { vector<set<ll>> tempedges(10001); FOR(i,0,U){ a.push_back(A[i]); b.push_back(B[i]); if (tempedges[A[i]].count(B[i])) tempedges[A[i]].erase(B[i]); else tempedges[A[i]].insert(B[i]); if (tempedges[B[i]].count(A[i])) tempedges[B[i]].erase(A[i]); else tempedges[B[i]].insert(A[i]); if (i%100==0) edges[i/100] = tempedges; } } int mindiff(set<ll>&a, set<ll>&b){ ll ans = 1000000000; vector<vector<ll>> A,B; for (auto&i : a) A.push_back({h[i], i}); for (auto&i : b) B.push_back({h[i], i}); sort(A.begin(), A.end()); sort(B.begin(), B.end()); ll l=0,r=0; while (l<A.size() && r<B.size()){ ans = min(ans, abs(A[l][0] - B[r][0])); if (A[l][0] < B[r][0]) l++; else r++; } return ans; } int question(int x, int y, int v) { v--; set<ll> X = edges[v/100][x]; set<ll> Y = edges[v/100][y]; FOR(i,(v/100)*100+1, v+1){ if (a[i] == x){ if (X.count(b[i])) X.erase(b[i]); else X.insert(b[i]); } if (a[i] == y){ if (Y.count(b[i])) Y.erase(b[i]); else Y.insert(b[i]); } if (b[i] == x){ if (X.count(a[i])) X.erase(a[i]); else X.insert(a[i]); } if (b[i] == y){ if (Y.count(a[i])) Y.erase(a[i]); else Y.insert(a[i]); } } return mindiff(X,Y); }

Compilation message (stderr)

potion.cpp: In function 'int mindiff(std::set<int>&, std::set<int>&)':
potion.cpp:45:13: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |     while (l<A.size() && r<B.size()){
      |            ~^~~~~~~~~
potion.cpp:45:27: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |     while (l<A.size() && r<B.size()){
      |                          ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...