QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#75035 | #5098. 第一代图灵机 | zuytong | 0 | 1166ms | 38744kb | C++14 | 2.6kb | 2023-02-04 14:39:45 | 2023-02-04 14:39:54 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define FOR(i, x, y) for(int i = (x); i <= (y); i++)
#define ROF(i, x, y) for(int i = (x); i >= (y); i--)
inline int rd()
{
int sign = 1, re = 0; char c = getchar();
while(!isdigit(c)){if(c == '-') sign = -1; c = getchar();}
while(isdigit(c)){re = re * 10 + (c - '0'); c = getchar();}
return sign * re;
}
const int N = 2e5 + 5;
int n, m, q;
int c[N];
LL a[N], sum[N];
set<int> pos[N];
namespace Seg
{
#define ls (now << 1)
#define rs (now << 1 | 1)
LL tr[N << 2]; int Mn[N << 2], Mx[N << 2];
LL calc(int now, int l, int r, int id)
{
if(Mx[now] <= id) return tr[now];
if(Mn[now] >= id) return sum[id - 1] - sum[l - 1];
int mid = (l + r) >> 1;
return max(calc(ls, l, mid, id), calc(rs, mid + 1, r, id));
}
LL query(int now, int l, int r, int L, int R, int &id)
{
if(L <= l && r <= R)
{
int re = calc(now, l, r, id + 1);
id = min(id, Mn[now]);
return re;
}
int mid = (l + r) >> 1; LL re = 0;
if(mid < R) re = query(rs, mid + 1, r, L, R, id);
if(L <= mid) re = max(re, query(ls, l, mid, L, R, id));
return re;
}
void modify(int now, int l, int r, int x, int y)
{
if(x < l || x > r) return;
if(l == r)
{
Mn[now] = Mx[now] = y;
tr[now] = sum[y - 1] - sum[l - 1];
return;
}
int mid = (l + r) >> 1;
if(x <= mid) modify(ls, l, mid, x, y);
else modify(rs, mid + 1, r, x, y);
Mn[now] = min(Mn[ls], Mn[rs]), Mx[now] = max(Mx[ls], Mx[rs]);
tr[now] = max(calc(ls, l, mid, Mn[rs]), tr[rs]);
}
} using namespace Seg;
signed main()
{
#ifndef ONLINE_JUDGE
freopen("test.in", "r", stdin);
freopen("test.out", "w", stdout);
#endif
n = rd(), m = rd(), q = rd();
FOR(i, 1, m) pos[i] = {0, n + 1};
FOR(i, 1, n) a[i] = rd(), sum[i] = sum[i - 1] + a[i];
FOR(i, 1, n) c[i] = rd(), pos[c[i]].insert(i);
FOR(i, 1, n) modify(1, 1, n, i, *(pos[c[i]].upper_bound(i)));
while(q--)
{
int ty = rd(), x = rd(), y = rd();
if(ty == 1) printf("%lld\n", query(1, 1, n, x, y, y));
else
{
auto it = pos[c[x]].lower_bound(x);
modify(1, 1, n, *prev(it), *next(it));
pos[c[x]].erase(it);
it = pos[y].upper_bound(x);
modify(1, 1, n, *prev(it), x);
modify(1, 1, n, x, *it);
c[x] = y, pos[y].insert(x);
}
}
return 0;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 62ms
memory: 20292kb
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:
2818126 3050606 799746 1570652 1533636 773336 412978 1548941 3050606 3050606 1533636 3050606 2818126 1577889 162138 809289 387165 207741 216931 1570652 3050606 2818126 2818126 39374 720527 2818126 218861 1577889 1548941 412072 788042 806470 2818126 3050606 3050606 1548941 3050606 1577889 3050606 437...
result:
wrong answer 1st lines differ - expected: '118571', found: '2818126'
Subtask #2:
score: 0
Wrong Answer
Test #3:
score: 0
Wrong Answer
time: 1166ms
memory: 38744kb
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:
19224919 18964152 14404481 15152467 16236577 18964152 18976316 19056018 14963838 18964152 9337104 9711494 18964152 15152467 19056018 18964152 16236577 16236577 19056018 18964152 18964152 10807982 11682508 16236577 15321988 18964152 19056018 18964152 18976316 15679772 9644170 18976316 18964152 189641...
result:
wrong answer 1st lines differ - expected: '1232419', found: '19224919'
Subtask #3:
score: 0
Time Limit Exceeded
Test #5:
score: 0
Time Limit Exceeded
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:
1268222792 718620135 631895136 1249314316 323545454 1258182368 1268222792 1252134624 1269680061 1249314316 89151137 341621222 1264182315 718620135 1260372829 1275922885 1268222792 1275922885 1260372829 1264182315 718620135 1261782475 333567280 642828463 710475450 1249314316 1264182315 94811596 12521...
result:
Subtask #4:
score: 0
Skipped
Dependency #1:
0%
Subtask #5:
score: 0
Skipped
Dependency #4:
0%