QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#67103#5098. 第一代图灵机yehaodee0 121ms13300kbC++143.4kb2022-12-10 09:16:002022-12-10 09:16:02

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-12-10 09:16:02]
  • Judged
  • Verdict: 0
  • Time: 121ms
  • Memory: 13300kb
  • [2022-12-10 09:16:00]
  • Submitted

answer

#include <bits/stdc++.h>
namespace IO {
#define iL (1 << 20)
char ibuf[iL], *iS = ibuf + iL, *iT = ibuf + iL;
#define gc() ((iS == iT) ? (iT = (iS = ibuf) + fread(ibuf, 1, iL, stdin), iS == iT ? EOF : *iS ++) : *iS ++)
template<class T> inline void read(T &x) {
	x = 0;int f = 0;char ch = gc();
	for (; !isdigit(ch); f |= ch == '-', ch = gc());
	for (; isdigit(ch); x = (x << 1) + (x << 3) + (ch ^ 48), ch = gc());
	x = (f == 1 ? ~ x + 1 : x);
}
template<class T, class... Args> inline void read(T &x, Args&... args) { read(x), read(args...); }
template<class T> inline void readch(T &x) { char ch = gc(); for (; !isalpha(ch); ch = gc()); x = ch; }
char Out[iL], *iter = Out;
#define flush() fwrite(Out, 1, iter - Out, stdout), iter = Out
template<class T> inline void write(T x, char ch = '\n') {
	T l, c[35];
	if (x < 0) *iter ++ = '-', x = ~ x + 1;
	for (l = 0; !l || x; c[l] = x % 10, l++, x /= 10);
	for (; l; -- l, *iter ++ = c[l] + '0');*iter ++ = ch;
	flush();
}
} // IO
using namespace IO;
#define N 200005
#define ll long long
#define DEBUG
#define pii pair<int, int>
#define mp make_pair
#define fi first
#define se second
using namespace std;
int n, m, q, a[N], c[N]; ll sum[N];
namespace sub1 {
#define kN 5005
void main() {
	for (int _ = 1, op, x, y; _ <= q; _++) {
		read(op, x, y); static int buc[kN]; memset(buc, 0, 4 * (m + 2));
		if (op == 1) {
			int R = x; buc[c[x]] ++; ll ans = 0;
			for (int i = x; i <= y; i++) {
				while (R < y && !buc[c[R + 1]]) { R ++; buc[c[R]] ++; }
				ans = max(ans, sum[R] - sum[i - 1]); buc[c[x]] --;
			}
			write(ans);
		}  else c[x] = y;
	}
}
} // sub1
namespace sub2 {
ll hans[N], mx[N * 4];
void modify(int k, int l, int r, int x, ll v) {
	if (l == r) { mx[k] = v; return ; }
	int mid = l + r >> 1;
	(x <= mid) ? modify(k << 1, l, mid, x, v) : modify(k << 1 | 1, mid + 1, r, x, v);
	mx[k] = max(mx[k << 1], mx[k << 1 | 1]);
}
int query(int k, int l, int r, int x, int y) {
	if (x <= l && r <= y) return mx[k];
	if (x > r || l > y) return 0;
	int mid = l + r >> 1; return max(query(k << 1, l, mid, x, y), query(k << 1 | 1, mid + 1, r, x, y));
}
void main() {
	for (int i = 1; i <= n; i++) {
		static int buc[15]; memset(buc, 0, sizeof buc);
		int R = i; buc[c[i]] ++;
		while (R < n && !buc[c[R + 1]]) { R ++; buc[c[R]] ++; }
		hans[i] = sum[R] - sum[i - 1]; modify(1, 1, n, i, hans[i]);
	}
	for (int _ = 1, op, x, y; _ <= q; _++) {
		read(op, x, y);
		if (op == 1) {
			int pl = max(y - m + 1, x); ll ans = 0;
			if (x < pl) ans = query(1, 1, n, x, pl - 1);
			for (int i = pl; i <= y; i++) {
				static int buc[15]; memset(buc, 0, sizeof buc);
				int R = i; buc[c[i]] ++;
				while (R < y && !buc[c[R + 1]]) { R ++; buc[c[R]] ++; }
				ans = max(ans, sum[R] - sum[i - 1]);
			}
			write(ans);
		}  else  {
			c[x] = y;
			int pl = max(x - m + 1, 1);
			for (int i = pl; i <= x; i++) {
				static int buc[15]; memset(buc, 0, sizeof buc);
				int R = i; buc[c[i]] ++;
				while (R < y && !buc[c[R + 1]]) { R ++; buc[c[R]] ++; }
				hans[i] = sum[R] - sum[i - 1]; modify(1, 1, n, i, hans[i]);
			}
		}
	}
}
} // sub2
int main() {
#ifndef ONLINE_JUDGE
	freopen("test.in", "r", stdin); freopen("test.out", "w", stdout);
#endif
	read(n, m, q);
	for (int i = 1; i <= n; i++) read(a[i]), sum[i] = sum[i - 1] + a[i]; for (int i = 1; i <= n; i++) read(c[i]);
	if (n <= 5000 && q <= 5000) { sub1::main(); return 0; }
	if (m <= 10) { sub2::main(); return 0; }
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 19ms
memory: 3536kb

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
22242
18771
34310
79205
63868
26197
32522
50915
39542
48056
42599
40109
32362
10599
21057
24573
71023
66795
39374
76754
8436
8927
24599
18959
40488
54682
33806
37897
35298
19016
50896
9045
8007
33839
8216
11457
70311
59662
47597
34378
40566
44336
21705
32164
55954
23123...

result:

wrong answer 1st lines differ - expected: '118571', found: '23933'

Subtask #2:

score: 0
Wrong Answer

Test #3:

score: 0
Wrong Answer
time: 121ms
memory: 13300kb

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:

1232419
1222519
1232419
1232419
1232419
1232419
1232419
1232419
1232419
1232419
1040511
1148070
1232419
1232419
1232419
1232419
1206368
1206368
1232419
1232419
1232419
1222519
1167757
1206368
1214212
1222519
1232419
1222519
1222519
1160928
1011843
1232419
1232419
1189403
1222519
1232419
1222519
1148...

result:

wrong answer 731st lines differ - expected: '973226', found: '856342'

Subtask #3:

score: 0
Wrong Answer

Test #5:

score: 0
Wrong Answer
time: 12ms
memory: 7500kb

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:


result:

wrong answer 1st lines differ - expected: '46702944', found: ''

Subtask #4:

score: 0
Skipped

Dependency #1:

0%

Subtask #5:

score: 0
Skipped

Dependency #4:

0%