제출 #1044527

#제출 시각아이디문제언어결과실행 시간메모리
1044527beaconmcThe Potion of Great Power (CEOI20_potion)C++14
38 / 100
3096 ms118752 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<ll> h; vector<ll> a; vector<ll> b; vector<vector<ll>> changes[100001]; vector<set<ll>> lotchange[100001]; 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; tempedges.resize(100001); FOR(i,0,U){ if (tempedges[A[i]].find(B[i]) != tempedges[A[i]].end()){ changes[A[i]].push_back({i, B[i]}); tempedges[A[i]].erase(B[i]); } else{ changes[A[i]].push_back({i, B[i]}); tempedges[A[i]].insert(B[i]); } if (tempedges[B[i]].find(A[i]) != tempedges[B[i]].end()){ changes[B[i]].push_back({i, A[i]}); tempedges[B[i]].erase(A[i]); } else{ changes[B[i]].push_back({i, A[i]}); tempedges[B[i]].insert(A[i]); } if ((changes[A[i]].size()-1)%50==0){ lotchange[A[i]].push_back(tempedges[A[i]]); } if ((changes[B[i]].size()-1)%50==0){ lotchange[B[i]].push_back(tempedges[B[i]]); } } } int mindiff(set<ll>&a, set<ll>&b){ ll ans = 1000000000; vector<ll> A,B; for (auto&i : a) A.push_back(h[i]); for (auto&i : b) B.push_back(h[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] - B[r])); if (A[l] < B[r]) l++; else r++; } return ans; return ans; } int question(int x, int y, int v) { v--; ll ans = 1000000000; ll pos = upper_bound(changes[x].begin(), changes[x].end(), vector<ll>{v, 1000000000})-changes[x].begin(); pos--; set<ll> X; if (pos >= 0){ X=lotchange[x][pos/50]; FOR(i, (pos/50)*50+1, pos+1){ ll temp = changes[x][i][1]; if (X.find(temp) != X.end()) X.erase(temp); else X.insert(temp); } } pos = upper_bound(changes[y].begin(), changes[y].end(), vector<ll>{v, 1000000000})-changes[y].begin(); pos--; set<ll> Y; if (pos >= 0){ Y=lotchange[y][pos/50]; FOR(i, (pos/50)*50+1, pos+1){ ll temp = changes[y][i][1]; if (Y.find(temp) != Y.end()) Y.erase(temp); else Y.insert(temp); } } return mindiff(X,Y); }

컴파일 시 표준 에러 (stderr) 메시지

potion.cpp: In function 'int mindiff(std::set<int>&, std::set<int>&)':
potion.cpp:69:13: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |     while (l<A.size() && r<B.size()){
      |            ~^~~~~~~~~
potion.cpp:69:27: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |     while (l<A.size() && r<B.size()){
      |                          ~^~~~~~~~~
potion.cpp: In function 'int question(int, int, int)':
potion.cpp:82:8: warning: unused variable 'ans' [-Wunused-variable]
   82 |     ll ans = 1000000000;
      |        ^~~
#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...