Submission #1043073

#TimeUsernameProblemLanguageResultExecution timeMemory
1043073beaconmcThe Potion of Great Power (CEOI20_potion)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #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<unordered_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<unordered_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(unordered_set<ll>&a, unordered_set<ll>&b){ ll ans = 1000000000; vector<vector<ll>> A,B; for (auto&i : a) A.push_back({h[i], 0}); for (auto&i : b) A.push_back({h[i], 1}); if (A.size()==0) return ans; sort(A.begin(), A.end()); FOR(i,0,A.size()-1){ if (A[i][1] != A[i+1][1]) ans = min(ans, abs(A[i][0]-A[i+1][0])); } return ans; } int question(int x, int y, int v) { v--; unordered_set<ll> X=edges[v/100][x]; unordered_set<ll> Y=edges[v/100][y]; FOR(i,(v/100)*100+1, v+1){ if (a[i] == x){ if (X.find(b[i]) != X.end()) X.erase(b[i]); else X.insert(b[i]); } if (a[i] == y){ if (Y.find(b[i]) != Y.end()) Y.erase(b[i]); else Y.insert(b[i]); } if (b[i] == x){ if (X.find(a[i]) != X.end()) X.erase(a[i]); else X.insert(a[i]); } if (b[i] == y){ if (Y.find(a[i]) != Y.end()) Y.erase(a[i]); else Y.insert(a[i]); } } return mindiff(X,Y); } void init(int N, int D, int F[]); void curseChanges(int U, int A[], int B[]); int question(int X, int Y, int V); int main() { int N, D, U, Q; std::ios::sync_with_stdio(false); std::cin.tie(NULL); std::cin >> N >> D >> U >> Q; int *F = new int[N]; for (int i=0; i<N; i++) std::cin >> F[i]; init(N, D, F); int *A = new int[U], *B = new int[U]; for (int i=0; i<U; i++) { std::cin >> A[i] >> B[i]; } curseChanges(U, A, B); bool correct = true; for (int i=0; i<Q; i++) { int X,Y,V,CorrectAnswer; std::cin >> X >> Y >> V >> CorrectAnswer; int YourAnswer = question(X,Y,V); if (YourAnswer != CorrectAnswer) { std::cout << "WA! Question: " << i << " (X=" << X << ", Y=" << Y << ", V=" << V << ") " << "Your answer: " << YourAnswer << " Correct Answer: " << CorrectAnswer << std::endl; correct = false; } else { std::cerr << YourAnswer << " - OK" << std::endl; } } if (correct) { std::cout << "Correct." << std::endl; } else std::cout << "Incorrect." << std::endl; return 0; }

Compilation message (stderr)

potion.cpp: In function 'int mindiff(std::unordered_set<int>&, std::unordered_set<int>&)':
potion.cpp:6:33: 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]
    6 | #define FOR(i,x,y) for(ll i=x; i<y; i++)
......
   45 |     FOR(i,0,A.size()-1){
      |         ~~~~~~~~~~~~~~           
potion.cpp:45:5: note: in expansion of macro 'FOR'
   45 |     FOR(i,0,A.size()-1){
      |     ^~~
/usr/bin/ld: /tmp/ccNfyWnC.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccbTBlGz.o:potion.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status