#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);
}
}
bool cmp(int x,int y) {return a[x] < a[y];}
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);
sort(all(l),cmp), sort(all(r),cmp);
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:54:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
54 | while(lp < l.size()&&rp < r.size()) {
| ~~~^~~~~~~~~~
potion.cpp:54:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
54 | while(lp < l.size()&&rp < r.size()) {
| ~~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
5100 KB |
Incorrect |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
5100 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
360 ms |
27780 KB |
Output is correct |
2 |
Correct |
354 ms |
27852 KB |
Output is correct |
3 |
Correct |
169 ms |
9576 KB |
Output is correct |
4 |
Execution timed out |
3066 ms |
17580 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
236 ms |
27880 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
11 ms |
6348 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
5100 KB |
Incorrect |