This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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];
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);
}
}
int question(int x,int y,int day) {
vec l,r;
x++, y++;
for(int i : v[x]) l.pb(i);
for(int i : v[y]) r.pb(i);
if(l.empty()||r.empty()) return INF;
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 (stderr)
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:52:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
52 | while(lp < l.size()&&rp < r.size()) {
| ~~~^~~~~~~~~~
potion.cpp:52:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
52 | while(lp < l.size()&&rp < r.size()) {
| ~~~^~~~~~~~~~
# | 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... |