#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define all(v) v.begin(),v.end()
#pragma gcc optimize("O3")
#pragma gcc optimize("Ofast")
#pragma gcc optimize("unroll-loops")
using namespace std;
const int INF = 1e9;
const int TMX = 1 << 18;
const long long llINF = 2e18;
const long long mod = 1e9+7;
const long long hashmod = 100003;
const int MAXN = 100000;
const int MAXM = 1000000;
typedef long long ll;
typedef long double ld;
typedef pair <int,int> pi;
typedef pair <ll,ll> pl;
typedef vector <int> vec;
typedef vector <pi> vecpi;
typedef long long ll;
set <int> v[100005];
vec v2[100005];
int n,m,d,a[100005];
vecpi edge;
void init(int N, int D, int H[]) {
n = N, d = D;
for(int i = 0;i < n;i++) {
a[i+1] = H[i];
}
}
void curseChanges(int U, int A[], int B[]) {
m = U;
for(int i = 0;i < m;i++) edge.pb({A[i]+1,B[i]+1});
for(pi i : edge) {
if(v[i.x].find(i.y) != v[i.x].end()) v[i.x].erase(i.y), v[i.y].erase(i.x);
else v[i.x].insert(i.y), v[i.y].insert(i.x);
}
}
bool cmp(int x,int y) {return a[x] < a[y];}
int question(int x,int y,int day) {
vec l,r;
x++, y++;
if(!v2[x].empty()) l = v2[x];
else {
for(int i : v[x]) l.pb(i);
sort(all(l),cmp);
v2[x] = l;
}
if(!v2[y].empty()) r = v2[y];
else {
for(int i : v[y]) r.pb(i);
sort(all(r),cmp);
v2[y] = r;
}
int ans = INF,lp = 0,rp = 0;
while(lp < l.size()&&rp < r.size()) {
ans = min(ans,abs(a[l[lp]]-a[r[rp]]));
if(a[l[lp]] < a[r[rp]]) lp++;
else rp++;
}
return ans;
}
Compilation message
potion.cpp:6: warning: ignoring #pragma gcc optimize [-Wunknown-pragmas]
6 | #pragma gcc optimize("O3")
|
potion.cpp:7: warning: ignoring #pragma gcc optimize [-Wunknown-pragmas]
7 | #pragma gcc optimize("Ofast")
|
potion.cpp:8: warning: ignoring #pragma gcc optimize [-Wunknown-pragmas]
8 | #pragma gcc optimize("unroll-loops")
|
potion.cpp: In function 'int question(int, int, int)':
potion.cpp:64:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
64 | while(lp < l.size()&&rp < r.size()) {
| ~~~^~~~~~~~~~
potion.cpp:64:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
64 | while(lp < l.size()&&rp < r.size()) {
| ~~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
7404 KB |
Incorrect |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
7532 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
335 ms |
32276 KB |
Output is correct |
2 |
Correct |
345 ms |
32100 KB |
Output is correct |
3 |
Correct |
133 ms |
11884 KB |
Output is correct |
4 |
Correct |
440 ms |
20708 KB |
Output is correct |
5 |
Correct |
420 ms |
30812 KB |
Output is correct |
6 |
Correct |
570 ms |
16876 KB |
Output is correct |
7 |
Correct |
257 ms |
16996 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
233 ms |
30072 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
11 ms |
8556 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
7404 KB |
Incorrect |