#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define int ll
typedef pair<int32_t, int32_t> pi;
typedef vector <int> vi;
typedef vector <pi> vpi;
typedef pair<pi, ll> pii;
typedef set <ll> si;
typedef long double ld;
#define f first
#define s second
#define mp make_pair
#define FOR(i,s,e) for(int i=s;i<=int(e);++i)
#define DEC(i,s,e) for(int i=s;i>=int(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define maxn 200010
#define INF (ll)1e9
#define MOD 1000000007
typedef pair <vi, int> pvi;
typedef pair <int,pi> ipi;
typedef vector <pii> vpii;
int H[maxn], N, D;
unordered_set <int> st[maxn][2];
vpi updates[maxn];
int last[maxn];
const int sqrtn = 300;
vpi sets[maxn];
void init(int N, int D, int H[]) {
::N = N; ::D = D;
FOR(i,0,N-1) ::H[i] = H[i];
FOR(i,0,N-1){
sets[i].pb(pi(pi(-1,-1)));
}
mem(last, -1);
}
void update(int x,int v, int t, int tt){
if (x == 3 && t == 9) cout << "AAAA" << last[x] << ' ' << updates[x].size() << '\n';
if (updates[x].size() - last[x] == sqrtn){
if (last[x] != -1 && updates[x][last[x]] != pi(-1,-1)) aFOR(j, st[updates[x][last[x]].f][updates[x][last[x]].s]) st[t][tt].insert(j);
FOR(i, last[x] + 1, updates[x].size() - 1){
int y = -updates[x][i].s; // index of person
assert(y >= 0);
if (st[t][tt].find(y) == st[t][tt].end()) st[t][tt].insert(y);
else st[t][tt].erase(y);
}
if (st[t][tt].find(v) == st[t][tt].end()) st[t][tt].insert(v);
else st[t][tt].erase(v);
updates[x].pb(pi(t, tt));
sets[x].pb(pi(t, updates[x].size() - 1));
last[x] = updates[x].size() - 1;
}else updates[x].pb(pi(t, -v));
}
void curseChanges(int U, int A[], int B[]) {
FOR(i,0,U-1){
update(A[i], B[i], i+1, 0);
update(B[i], A[i], i+1, 1);
}
}
set <int> get_set(int x, int v){
int idx = (--ubd(sets[x], pi(v, INF)))->s;
set <int> ans;
if (idx != -1){
pi t = updates[x][idx];
assert(t.s == 0 || t.s == 1);
//cout << "t " << t.f << '\n';
if (t.f != -1) aFOR(i, st[t.f][t.s]) ans.insert(i);
}
for (int i = idx + 1; i < (int)updates[x].size() && updates[x][i].f <= v; i++){
int z = -updates[x][i].s;
assert(z >= 0);
if (ans.find(z) == ans.end()) ans.insert(z);
else ans.erase(z);
}
/*
cout << "SET " << x << ' ' << v << '\n';
aFOR(i, ans) cout << i << ' ';
cout << "\n";
*/
//return ans;
set <int> actl_ans;
aFOR(i, ans) actl_ans.insert(H[i]);
return actl_ans;
}
int question(int x, int y, int v) {
//get_set(x, 9);
//cout << '\n';
set <int> xst = get_set(x, v);
set <int> yst = get_set(y, v);
int ans = INF;
aFOR(i, xst){
auto it = yst.lower_bound(i);
if (it != yst.end()) ans = min(ans, *it - i);
if (it != yst.begin()) ans = min(ans, abs(*(--it) - i));
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
20 ms |
32336 KB |
Expected integer, but "AAAA-1" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
32464 KB |
Output is correct |
2 |
Correct |
18 ms |
32500 KB |
Output is correct |
3 |
Correct |
22 ms |
32464 KB |
Output is correct |
4 |
Correct |
34 ms |
36320 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
233 ms |
44108 KB |
Output is correct |
2 |
Correct |
234 ms |
44140 KB |
Output is correct |
3 |
Correct |
1074 ms |
41980 KB |
Output is correct |
4 |
Execution timed out |
3070 ms |
45668 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
173 ms |
44160 KB |
Output is correct |
2 |
Execution timed out |
3052 ms |
52940 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
66 ms |
33216 KB |
Output is correct |
2 |
Correct |
321 ms |
33108 KB |
Output is correct |
3 |
Correct |
1296 ms |
33092 KB |
Output is correct |
4 |
Execution timed out |
3091 ms |
33372 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
20 ms |
32336 KB |
Expected integer, but "AAAA-1" found |
2 |
Halted |
0 ms |
0 KB |
- |