QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#125558 | #6533. Traveling in Cells | definieren | RE | 0ms | 0kb | C++14 | 2.9kb | 2023-07-16 21:00:02 | 2023-07-16 21:00:06 |
Judging History
answer
#include <set>
#include <map>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <cstdio>
#include <vector>
#include <cstring>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>
#define fir first
#define sec second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef vector<int> vi;
typedef vector<pii> vpii;
template<typename T> T read() {
T x = 0; int f = 1; char ch = getchar();
while (ch < '0' || ch > '9') f = ((ch == '-') ? (~f + 1) : f), ch = getchar();
while (ch >= '0' && ch <= '9') x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
return x * f;
}
const int MOD = 998244353;
template<typename T> T add(T a, T b) { return (a + b >= MOD) ? (a + b - MOD) : (a + b); }
template<typename T> T del(T a, T b) { return (a - b < 0) ? (a - b + MOD) : (a - b); }
template<typename T> T cadd(T &a, T b) { return a = add(a, b); }
template<typename T> T cdel(T &a, T b) { return a = del(a, b); }
template<typename T> T cmax(T &a, T b) { return a = max(a, b); }
template<typename T> T cmin(T &a, T b) { return a = min(a, b); }
bool Mbe;
const int MAXN = 1e5+9;
int n, q, c[MAXN], v[MAXN], a[MAXN];
int rt[MAXN], cnt[MAXN], ls[MAXN], rs[MAXN];
ll bit[MAXN];
void Update(int x, int k) {
for (; x <= n; x += x & -x)
bit[x] += k;
return;
}
ll Query(int x) {
ll ans = 0;
for (; x; x -= x & -x)
ans += bit[x];
return ans;
}
int New_Node() {
static int tot = 0;
return ++tot;
}
void Push_Up(int p) {
cnt[p] = cnt[ls[p]] + cnt[rs[p]];
return;
}
void Update(int &p, int pos, int w, int L = 1, int R = n) {
if (!p) p = New_Node();
if (L == R) {
cnt[pos] += w;
return;
}
int Mid = L + R >> 1;
if (pos <= Mid) Update(ls[p], pos, w, L, Mid);
else Update(rs[p], pos, w, Mid + 1, R);
Push_Up(p); return;
}
int Get_Left(int x){
}
bool Med;
int main() {
freopen(".in", "r", stdin);
freopen(".out", "w", stdout);
fprintf(stderr, "%.3lf Mb\n", fabs((&Mbe - &Med) / 1048576.0));
int T = read<int>();
while (T--) {
n = read<int>(), q = read<int>();
for (int i = 1; i <= n; i++)
c[i] = read<int>(), Update(rt[c[i]], i, 1);
for (int i = 1; i <= n; i++)
v[i] = read<int>(), Update(i, v[i]);
while (q--) {
int opt = read<int>();
if (opt == 1) {
int p = read<int>(), x = read<int>();
Update(rt[c[p]], p, -1);
c[p] = x;
Update(rt[c[p]], p, 1);
} else if (opt == 2) {
int p = read<int>(), x = read<int>();
Update(p, -v[p]), Update(p, v[p] = x);
} else {
int x = read<int>(), k = read<int>();
for (int i = 1; i <= k; i++)
a[k] = read<int>();
int l = Get_Left(x), r;
}
}
}
fprintf(stderr, "%d ms", clock());
fclose(stdin), fclose(stdout);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Dangerous Syscalls
input:
2 5 10 1 2 3 1 2 1 10 100 1000 10000 3 3 1 3 3 3 2 2 3 2 5 20000 2 3 200 3 3 2 1 3 3 3 3 1 2 3 1 3 4 2 1 100000 1 2 2 3 1 2 1 2 4 1 1 2 3 4 1000000 1000000 1000000 1000000 3 4 4 1 2 3 4