QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#332969 | #7877. Balanced Array | wcyQwQ | TL | 1ms | 5736kb | C++14 | 1.4kb | 2024-02-19 16:42:10 | 2024-02-19 16:42:10 |
Judging History
answer
#include <bits/stdc++.h>
#define L(i, j, k) for (int i = (j); i <= (k); i++)
#define R(i, j, k) for (int i = (j); i >= (k); i--)
using namespace std;
using LL = long long;
const int mod = 19260817, B = 131, N = 2e6 + 10;
int pw[N], pr[N], dt[N];
template<class T = int> T read() {
T x = 0;
char c = getchar();
while (c == ' ' || c == '\n') {
c = getchar();
}
while (c != ' ' && c != '\n') {
int w = 0;
if (c >= '0' && c <= '9') {
w = c - '0';
}
else if (c >= 'a' && c <= 'z') {
w = c - 'a' + 10;
}
else {
w = c - 'A' + 36;
}
x = x * 62 + w, c = getchar();
}
return x;
}
int F(int l, int r) {
return (pr[r] - (LL)pr[l - 1] * pw[r - l + 1] % mod + mod) % mod;
}
int main() {
int n = read();
pw[0] = 1;
L(i, 1, n) {
int x = read();
pw[i] = (LL)pw[i - 1] * B % mod;
pr[i] = ((LL)pr[i - 1] * B + x) % mod;
}
int R = 0;
L(k, 1, (n - 1) / 2) {
R = max(R, 2 * k);
while (R < n && (F(1, R + 1 - 2 * k) + F(2 * k + 1, R + 1)) % mod == (LL)2 * F(k + 1, R + 1 - k) % mod) {
R++;
}
dt[2 * k + 1]++, dt[R + 1]--;
}
L(i, 1, n) {
dt[i] += dt[i - 1];
putchar(!!dt[i] + '0');
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5736kb
input:
3 1 2 3
output:
001
result:
ok single line: '001'
Test #2:
score: 0
Accepted
time: 1ms
memory: 5548kb
input:
9 1 2 3 2 5 4 3 8 5
output:
001010111
result:
ok single line: '001010111'
Test #3:
score: 0
Accepted
time: 0ms
memory: 5576kb
input:
9 1C 3f 4S 3h 88 6x 4W d1 8c
output:
001010111
result:
ok single line: '001010111'
Test #4:
score: -100
Time Limit Exceeded
input:
49 71FjQ 71FzG 71FjR 71FjG 71FjS 71F3G 71FjT 71ENG 71FjU 71ExG 71FzG 71Fko 71FjW 71FOM 71FPm 71FzG 71FPO 71FP9 71FzG 71Fkc 71FzG 7AXBr 71FPH 8nKLh 71Fk2 71FzG 71FkK 4AGIE 71Fk9 6EfCL 71FPN 71FjJ 71FPb 7H3TC 71Gks 71FzG 71FPI 71FzG 6Oayg 71FPc 71FPw 71FPN 71Fkm 71FPK 71FPK 6Az4J 71FPI 71FzG 71Fke