QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#67260 | #5098. 第一代图灵机 | czxb2 | 0 | 475ms | 31268kb | C++14 | 2.1kb | 2022-12-10 11:14:26 | 2022-12-10 11:14:28 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#ifdef ONLINE_JUDGE
#define freopen(...) 0
#endif
#define IO(a) freopen(#a".in", "r", stdin), freopen(#a".out", "w", stdout),\
cin.tie(0)->sync_with_stdio(0), cout.tie(0)
#define F(i, a, b) for (int i = (a), iee = (b); i <= iee; i++)
#define R(i, a, b) for (int i = (a), iee = (b); i >= iee; i--)
#define fi first
#define se second
using ll = long long;
using pr = pair<ll, int>;
const int N = 200100;
int n, m, q, b[N], c[N];
ll a[N];
int nxt[N];
set<int> pos[N];
#define lc p << 1
#define rc p << 1 | 1
#define mid ((l + r) >> 1)
int mn[N << 2];
ll res[N << 2];
ll query(int z, int l, int r, int p) {
if (z < mn[p]) return 0;
if (l == r) return a[z] - a[l];
if (z < mn[rc])
return query(z, l, mid, lc);
else
return min(query(z, mid + 1, r, rc), res[p]);
}
ll query(int x, int y, int &z, int l, int r, int p) {
if (x > r || y < l || z < mn[p]) return 0;
if (x <= l && y >= r) {
ll ret = query(z, l, r, p);
z = min(z, mn[p] - 1);
return ret;
}
ll u = query(x, y, z, mid + 1, r, rc);
ll v = query(x, y, z, l, mid, lc);
return max(u, v);
}
void modify(int x, int k, int l, int r, int p) {
if (x < l || x > r) return;
if (l == r) { mn[p] = k; return; }
modify(x, k, l, mid, lc), modify(x, k, mid + 1, r, rc);
mn[p] = min(mn[lc], mn[rc]);
res[p] = query(mn[rc] - 1, l, mid, lc);
}
void modify(int x, int y) {
nxt[x] = y;
modify(x, y, 1, n, 1);
}
int main() {
IO(machine);
cin >> n >> m >> q;
F(i, 1, n) cin >> a[i], a[i] += a[i - 1];
F(i, 1, m) pos[i] = {0, n + 1};
F(i, 1, n) cin >> c[i], pos[c[i]].insert(i);
F(i, 1, n) modify(i, *pos[c[i]].upper_bound(i));
F(i, 1, q) {
int op, x, y;
cin >> op >> x >> y;
if (op == 1) {
int z = y;
ll ans = query(x, y, z, 1, n, 1);
ans = max(ans, a[z] - a[x - 1]);
cout << ans << "\n";
} else {
if (c[x] == y) continue;
auto it = pos[c[x]].find(x);
modify(*prev(it), *next(it));
pos[c[x]].erase(x);
c[x] = y;
pos[c[x]].insert(x);
it = pos[c[x]].find(x);
modify(*prev(it), x), modify(x, *next(it));
}
}
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 8ms
memory: 13264kb
input:
5000 200 5000 2315 3433 1793 4621 4627 4561 289 4399 3822 2392 392 4581 2643 2441 4572 4649 2981 3094 4206 2057 761 2516 2849 3509 3033 658 4965 3316 3269 4284 4961 753 1187 2515 1377 1725 4743 4761 3823 3464 4859 989 2401 953 875 1481 2181 103 2067 2625 3296 4721 61 3843 1607 997 4385 1284 4299 441...
output:
23933 53092 16130 46803 26863 23414 18771 58994 79205 63868 26197 32522 50915 39542 48056 42599 40109 32362 31218 21057 24573 70000 66795 39374 76754 8436 67244 36751 18959 40488 54682 33806 37897 35298 19016 50896 39693 8007 33839 26114 11457 70311 55301 47597 34378 40566 44336 21705 32164 55954 23...
result:
wrong answer 1st lines differ - expected: '118571', found: '23933'
Subtask #2:
score: 0
Wrong Answer
Test #3:
score: 0
Wrong Answer
time: 475ms
memory: 29368kb
input:
200000 10 200000 55651 97298 108697 86619 60721 199951 10610 162267 154301 138848 39191 18605 101369 57073 34977 101576 71252 143401 89587 160521 166491 38442 150761 35579 25571 121311 38033 38483 144639 41401 179161 54872 157905 137601 46863 187656 171901 43715 41036 150741 69057 102031 130561 4772...
output:
510429 431528 340998 784031 174838 280535 278494 400799 385674 271117 371636 322147 678015 641904 1055976 659489 378168 655664 343529 364316 566987 505184 246378 319691 509137 325155 364812 549698 818754 291155 253650 448085 384461 557311 627863 252470 566367 240947 300921 280413 645034 344880 47110...
result:
wrong answer 1st lines differ - expected: '1232419', found: '510429'
Subtask #3:
score: 0
Wrong Answer
Test #5:
score: 0
Wrong Answer
time: 348ms
memory: 31268kb
input:
200000 20000 200000 30681 32496 35471 48191 159123 69792 120915 150673 187226 158493 36275 26856 107976 124777 145229 69745 183961 14497 144808 153612 185893 137681 66417 46802 19345 113322 168046 128149 191001 135433 13201 139214 59489 81178 42343 163158 110121 119201 97501 53079 158755 192241 1132...
output:
10674861 11565528 11035239 5438264 5911160 10582729 27755020 4343302 20726277 16928534 11115858 16836200 21953546 9231854 6698804 11065651 19852826 19886692 8971620 2853352 17102223 27933467 3131169 10220412 4197477 16097273 25973934 3268575 15967677 37191041 1635668 9064292 21438486 5948561 1528301...
result:
wrong answer 1st lines differ - expected: '46702944', found: '10674861'
Subtask #4:
score: 0
Skipped
Dependency #1:
0%
Subtask #5:
score: 0
Skipped
Dependency #4:
0%