#include <bits/stdc++.h>
typedef long long 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(vector<ll>&a, vector<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;
set<ll> Y;
for (auto&i : edges[v/100][x]) X.insert(i);
for (auto&i : edges[v/100][y]) Y.insert(i);
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]);
}
}
vector<ll> XX,YY;
for (auto&i : X) XX.push_back(i);
for (auto&i : Y) YY.push_back(i);
return mindiff(XX,YY);
}
Compilation message
potion.cpp: In function 'int mindiff(std::vector<long long int>&, std::vector<long long int>&)':
potion.cpp:45:13: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::vector<long long 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 'long long int'} and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
45 | while (l<A.size() && r<B.size()){
| ~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1368 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
7344 KB |
Output is correct |
2 |
Correct |
5 ms |
7512 KB |
Output is correct |
3 |
Correct |
4 ms |
7512 KB |
Output is correct |
4 |
Runtime error |
10 ms |
4380 KB |
Execution killed with signal 11 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
26 ms |
7372 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
29 ms |
7452 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
184 ms |
150528 KB |
Output is correct |
2 |
Correct |
138 ms |
63348 KB |
Output is correct |
3 |
Correct |
307 ms |
60504 KB |
Output is correct |
4 |
Correct |
2033 ms |
120144 KB |
Output is correct |
5 |
Correct |
2019 ms |
138576 KB |
Output is correct |
6 |
Correct |
244 ms |
101200 KB |
Output is correct |
7 |
Correct |
1611 ms |
71240 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1368 KB |
Output is correct |
2 |
Correct |
5 ms |
7344 KB |
Output is correct |
3 |
Correct |
5 ms |
7512 KB |
Output is correct |
4 |
Correct |
4 ms |
7512 KB |
Output is correct |
5 |
Runtime error |
10 ms |
4380 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |