이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
tempedges.resize(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], 0});
for (auto&i : b) A.push_back({h[i], 1});
sort(A.begin(), A.end());
if (A.size()==0) return ans;
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--;
ll fuck = (v/100);
set<ll> X = edges[fuck][x];
set<ll> Y = edges[fuck][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);
}
컴파일 시 표준 에러 (stderr) 메시지
potion.cpp: In function 'int mindiff(std::set<int>&, std::set<int>&)':
potion.cpp:4: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]
4 | #define FOR(i,x,y) for(ll i=x; i<y; i++)
......
44 | FOR(i,0,A.size()-1){
| ~~~~~~~~~~~~~~
potion.cpp:44:5: note: in expansion of macro 'FOR'
44 | FOR(i,0,A.size()-1){
| ^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |