QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#332314 | #7877. Balanced Array | Yansuan_HCl | WA | 140ms | 40636kb | C++14 | 1.8kb | 2024-02-19 14:06:00 | 2024-02-19 14:06:00 |
Judging History
answer
#include <bits/stdc++.h>
#define ms(x, v) memset(x, v, sizeof(x))
#define il __attribute__((always_inline)) static
#define U(i,l,r) for(int i(l),END##i(r);i<=END##i;++i)
#define D(i,r,l) for(int i(r),END##i(l);i>=END##i;--i)
using namespace std;
using ll = long long;
#define IC isdigit(c)
#define GC c=getchar()
void rd(auto &x) { x = 0; char GC; bool f = 0;
for (; !IC; GC) f |= c == '-';
for (; IC; GC) x = x * 10 + c - 48;
if (f) x = -x;
}
void rd(auto &x, auto &...y) { rd(x); rd(y...); }
#define meow(...) fprintf(stderr, __VA_ARGS__)
#define Assert(e) if (!(e)) { meow("AF@%d\n", __LINE__); exit(__LINE__); }
// 等差数列的第二类定义
// a1 + a3 = 2a2
const int N = 2000006; const ll P = 998244353, BASE = P - 3;
int n, a[N]; ll hsh[N] {}, pb[N] {};
ll query(int l, int r) {
return (hsh[r] - hsh[l - 1] * pb[r - l + 1] % P + P) % P;
}
int main() {
pb[0] = 1; U (i, 1, N - 1) pb[i] = pb[i - 1] * BASE % P;
// freopen("arrebol.in", "r", stdin);
// freopen("arrebol.out", "w", stdout);
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
cin >> n;
U (t, 1, n) {
char s[32] {};
cin >> s+1;
int len = strlen(s+1);
for(int i=1,now;i<=len;i++){
if('0'<=s[i] && s[i]<='9') now = s[i]-'0';
else if('a'<=s[i] && s[i]<='z') now = 10+s[i]-'a';
else now = 36+s[i]-'A';
a[t] = a[t]*62+now;
}
hsh[t] = (hsh[t - 1] * BASE + a[t]) % P;
}
int ans = 0;
for (int i = 1, k = 1; i <= n; ++i) {
while (1) { // check k;
if (k * 2 + 1 > i) break;
int l = i - (k * 2 + 1) + 1;
ll h1 = query(1, l),
h2 = query(k + 1, k + l),
h3 = query(k * 2 + 1, k * 2 + l);
if ((h1 + h3) % P == h2 * 2 % P)
break;
++k;
}
printf("%d", int(k <= (i - 1) / 2));
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 11ms
memory: 20692kb
input:
3 1 2 3
output:
001
result:
ok single line: '001'
Test #2:
score: 0
Accepted
time: 7ms
memory: 21324kb
input:
9 1 2 3 2 5 4 3 8 5
output:
001010111
result:
ok single line: '001010111'
Test #3:
score: 0
Accepted
time: 7ms
memory: 19864kb
input:
9 1C 3f 4S 3h 88 6x 4W d1 8c
output:
001010111
result:
ok single line: '001010111'
Test #4:
score: 0
Accepted
time: 5ms
memory: 20096kb
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
output:
0000111111001000000000001000000000110000100000001
result:
ok single line: '0000111111001000000000001000000000110000100000001'
Test #5:
score: 0
Accepted
time: 10ms
memory: 21124kb
input:
48 4LZe2 4LZt4 4LZI6 4LZX8 4LZtY 4LZe2 4LZtX 4LZe2 4LYYd 4LYZ2 4LYZy 4LZe2 4LZtG 4LZtT 4LZe2 4LYtm 6g6ce 4LZe2 4LYYI 8MRDV 4LZu3 6tLzK 4WUft 7EU0p 5FVal 4LZe2 4LZe2 4LZu8 4LZe2 4LXtE 7KcGm 4LYXX 4LYYn 5v3aX 4LZtC 4LZu3 4LZe2 4LYYI 4LZtQ 4TSBp 4LYYB 4LZe2 4MatY 4LYYi 57PgU axOxK 6zQCA 4LZe2
output:
001100000000001100000000000011100000000000001110
result:
ok single line: '001100000000001100000000000011100000000000001110'
Test #6:
score: 0
Accepted
time: 3ms
memory: 19628kb
input:
50 6NIbv 6ZUpG 7c6DR 7oiS2 6NIbv 6NIbv 8Uivo 6NIbv 6NIqD 6NIbv 6NHWa 6NHVS 6NIrs 6NIrB 6NIqy 84jAs 6NIFL 6BvXk 6NHW0 6NIqV 6NIqZ 6NIr3 6NHGf 6NHVY 6NIrC 6NHVT 6NIqp 6NIbv 6NIFB 6NHW8 4TPq0 6NHVq 6NJa1 6NIbv 6NIbv 6NHVG 6NHGv 6Bwsa 6pke7 6NIbv 6NIGt 6Bwsq 6piID 6d6ZU 6NIrk 6NIr4 6NHVR 5c7Qh 6NIrv 6NHVQ
output:
00110000000000001100001000001000100011101111000000
result:
ok single line: '00110000000000001100001000001000100011101111000000'
Test #7:
score: 0
Accepted
time: 6ms
memory: 20764kb
input:
47 6vtDV 6vtTo 6vu8v 6vtE6 6vuD5 6vtDE 6vtEj 6vtDz 6vvCf 6vtnU 4Mrgd 5NjpO 6vtEH 6vu99 6vtDd 6vxl6 6vtDw 6vu8V 5RBQQ 8XwN1 6vtTo 5K2nw 7UTxg 6vu8U 6vu94 6vu9o 6vtTo 6vu8W 6vu9u 6vtTo 6vB2h 6vtnE 6vu9l 5dK3A 6vtE8 6vtDA 5dK3L bpzGE 6vtEh 4YB6W 9kirr 6vuEa 6vuDP 6vtTo 6vu99 6vu8H 6vtTo
output:
00001000110010110000000000000011110011111110000
result:
ok single line: '00001000110010110000000000000011110011111110000'
Test #8:
score: 0
Accepted
time: 10ms
memory: 20296kb
input:
43 4HIA8 4HI4x 4HI4a 4HI4a 4HIzV 4HIzQ 63TJC 4HIk5 4HIzI 4HIAc 4HIzy 4HIA5 7q4T6 4HIk5 4HI42 4HIk5 4HIzi 4HJ5R 4HJ4W 4HJ60 4HIk5 4HI52 6jqi6 4HIA2 a8rc4 4HIzD 4HI3U 6UCuG 4HIk5 66aXe 4HIA4 4HIk5 4HIk5 4HIk5 4HIA6 4HIA2 4HJzK 4HI4R 4HJBS 4HIk5 4HIzj 6lBPF 4HHzW
output:
0000000010101010111100001110000000001010001
result:
ok single line: '0000000010101010111100001110000000001010001'
Test #9:
score: 0
Accepted
time: 10ms
memory: 20396kb
input:
877 5dUft 5dTKA 5dUfb 5dU0n 5dTLe 5dU0n 5dUfZ 5dUfW 5dU0n 5dU0n 5dU0n 5dUg0 5dU0n 5dUgp 5dUgp 5dUga 5dTLz 5dU0n 5dUKM 5dU0n 5dUgP 5dUgS 5dUvX 5dTwL 5dU0n 5dTKA 5dU0n 5dTKI 5dTKY 5dU0n 5dU0n 5dUg8 5dThF 5dUga 5dVgn 5dU0n 5dUfN 5dTKL 5dU0n 5dU0n 5dTKv 5dTKt 5dU0n 5dU0n 5dUeZ 5dTKI 5dU0n 5dUfq 5dU0n 7U...
output:
000000000000001111111111100000001111000000000000000010000000110000111110000000000000000000000010001110000000000000000000000000000000000000000000111111100000001000000000000000000011000000000011001000000000001100111110000000000011110000000000111111111111111100111111111000000000000000000000000011000000...
result:
ok single line: '000000000000001111111111100000...1111111100001111110000111111111'
Test #10:
score: 0
Accepted
time: 7ms
memory: 19988kb
input:
969 8ZtYL 8ZtJI 8ZueD 8ZtYL 8ZtJh 5MmwD 8ZtYL 8ZueS 8ZueR 8ZtID 8ZtIZ 8ZtYL 8ZueT 8ZtYL 8ZtIH 8ZtII 8ZuuX 8ZtHy 8Ztdl 8ZtIW 8ie68 8ZueK 8ZueN 8ZtYL 8ZtYL 8Zuet 6WmHa 8ZtJR 8ZueN 7hWYh 8ZtYL 8ZueL 8ZtJ0 8Zues 8ZtYL 4MAd1 8ZtYL 8ZtIW 8ZueM 8ZtYL 8ZtJA 8ZueE 8ZueQ 8ZtIF 8ZtYL 8ZtYL 8ZtYL 8ZtYL 8ZtIN 8Z...
output:
000000100000000011100000000000000000000000000010000000111011111100000000000000000000000010000000001111111110000000111100111000000011000000111111111111000000000000000000000000100011100000111111111000000011000010000000000000000000000000000011110000101100000011111111111110000000111111110000001000000000...
result:
ok single line: '000000100000000011100000000000...1111111110100000001111001111111'
Test #11:
score: 0
Accepted
time: 5ms
memory: 19780kb
input:
957 52EFb 52Epl 52Epl 52EEh 52E9e 52E9w 52EDn 52DT7 52Epl 52EEY 52E9f 52E9H 52EF6 52E9f 52Epl 52Ea3 52E9v 52EUB 52E9l 8ahpl 52DDj 52DU3 52EUR 52DEd 52EFs 52EaA 52EFc 52EaC 8ZnAe 52EFq 52Epl 52EFl 52EEO 7X1Ra 52Epl 52Epl 8pSGU 52EEK 52EFo 52Ea0 52CBr 52DoL 52Fqn 52CE9 52Ea5 52Eau 52EFh 52E9V 52EFq 52...
output:
000000110000000011001111110000000000000011110000000000000011111111110000000000000000000011111000001100111100000000111000000000000000111111111111001111111111111111100011001000000010100000000000000010111111111111111111110000111011111110000000111100000000111111111000000000110000000000000000000000100000...
result:
ok single line: '000000110000000011001111110000...0000000000111111111100001100000'
Test #12:
score: 0
Accepted
time: 7ms
memory: 21424kb
input:
990 74n7K 74n6R 74nCP 74n6Z 74o7U 74n77 74oCZ 74n7f 74p84 7f5lh 74nmP 74nmP 74n6U 74nmP 74nCW 74n6W 74r8o 7pNzH 74n74 4LqKL 74nBU 74nCN 74mAZ 74nCF 74n7Y 74n6L 74tDN 7Le29 74l64 2hMaf 74nQZ 74nSL 74m54 74nSv 4XPoO 74nmP 74nmP 74nCE 8FhCh 59GcQ 74nBJ 74nB5 7km2a 74n6J 74n7S 74nmP 74o7A 74n95 74mAH 74...
output:
000011111000000011001111111111111100000000000011111100000000001111111100000000000000000011100000000000001111111111111000001111001000000000110011000011111111111111111000000000111111111111111110000000110000001000000000000000000000000000111000001111111111111100100000000000000000001110111011111110000000...
result:
ok single line: '000011111000000011001111111111...1111111000000000000000000100011'
Test #13:
score: 0
Accepted
time: 10ms
memory: 19760kb
input:
982 6Jrhz 6Jh9W 6ExFp 6Jrhz 6Jrhz 6Jr2e 6Jr1x 6Jrhz 6Jrhz 6JAUw 6OknF 6Jrhz 6Jrhz 6JKMO 6TdJN 6Jrhz 6Jrhz 6JUF6 6Jr2K 6JrxD 6JrxF 6JrwV 6Jrhz 6Jrhz 6Jrxo 6Jrww 6Jr1B 6JrwL 6Jrxh 6Jrhz 8QNyX 6Jrhz 8TriU 6Jr1v 6JrwC 6JrxG 6Jrxr 6Jr1K 6Jrhz 6Jr1w 6Jrhz 6Jrxq 6Jr1r 82aCg 8gIEI 6Jrxf 8muA9 6ANOY 6Jr1A 6J...
output:
000000001111111111000010000000000000000000000000000000000010111000001111111110000011110000000000000000000000000000001100000000000000000011111111001111111111111000000000000000000000100000001110000000000000001000000011111111111111111110000000001100000000100011111110101000001111100010000000000000000000...
result:
ok single line: '000000001111111111000010000000...1111111111111000010000000000000'
Test #14:
score: 0
Accepted
time: 9ms
memory: 22196kb
input:
94739 4VFIg 4VFY4 4VFYe 4VFY9 4VFse 4VFYk 4VFIg 4VFs8 4VFIg 4VFsM 4VFsy 4VFIg 4Hptu 4VFYg 6L0BB 4VFsu 4VFIg 4VFIg 4VFsT 8egOH 4VFIg 4VFIg 4VFXH 4VFsh 6oAAx 4VFsj 4VFsq 4VFXY 8AluW 4VEWU 4VFsi 4VFsn 4VFty bwRF4 4VFIg 4VFYo 4VGd8 4VFrM 7RvIw 4VFcm 59Vrm 4VFXG apGoh 4VErk 4VFck 4VFcu 4VFud 4VFYi 4VFsd ...
output:
000000000000000010000000000011111111111111111110000000000000000000001111111100000000000000000011111111111111111111111110000000000000000000111010000000000000000000000000100000000000000000000000000000000000111111111110000000000000000000000000000000100000000000000000000000000000000000000000000000000000...
result:
ok single line: '000000000000000010000000000011...0010000000100000000000000000000'
Test #15:
score: 0
Accepted
time: 12ms
memory: 20724kb
input:
81569 5uyVE 5uyVT 5uzbH 5uzbH 5uzru 5uyW9 6SM4S 8Pimo 5uyVC 5uyVz 5uyWE 8gZdR ca1x5 5uyFx 5uypE 5uyX9 9FcmQ 5uyW7 5uzbH 5uzrJ 5uzrA 5uzbH 4X6Bc 6b4rk 5uyVz 5uyVN 5uyVE 5uzr4 5uzrK 5uzrO 5uzbH 5uyXs 5uzbH 5uyVK 5uzrs 5uzrv 5uzrC 5uzbH 5uzrt 5uzbH 5uzbH 5uzbH 5uyVC 4TXnU 5uyW9 5uzro 5uzqZ 5uyVA 5uzr7 ...
output:
000000000011111110000000000000000000000000000000000000000000000000000000000011111111111100000000000000000000000000001111111111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111111000000000000000000000000000000000000111111111111000000000000...
result:
ok single line: '000000000011111110000000000000...0000000000000000001111111111100'
Test #16:
score: 0
Accepted
time: 13ms
memory: 21536kb
input:
83999 6FaDi 6Fa8w 6FaDH 5ZQMm 6FanC 6Fa7S 6FanC 6Fa7B 5XnBq 6Fa7V 6FaDi 6FaDD 6FaDu 6FanC 4Bhya 6FaDl 6FaDo 6FaDa 6Fa7y 6IAun 6FaDI 6NfgT 6Fa8y 6Fa7L 6FanC 6FaDy 6Fa7x 6FanC 6FanC 6FaDm 6FaDo 6Fb8g 6FaCD 6Fa7K 4XBxM 6FanC 6FaDu 6Fa8r 6Fa7u 6FaDK 6FanC 6FanC 7MbUE 6Fa7H 6Fa8k 6FaDG 6Fa7x 6FaDl 6FaDz ...
output:
000000000000000000000000000000111000000000000000000000000000000000001111111110000000000000000000000000000000000011111111111100000000001000001111111111110000000000111111111111111111111111000000000000000000000000100000000000000000000000000000000000000000000000000000000000001111111100000000000000000000...
result:
ok single line: '000000000000000000000000000000...0000000000000000000000000000000'
Test #17:
score: 0
Accepted
time: 17ms
memory: 20760kb
input:
96726 5gC3t 5gBxX 5gBxZ 5gC26 5gBNw 5gBNw 6LPnj 5gBNw 5gBNw 5gC3u 8QrA4 5gBNw 8h2H9 5gC35 5gC33 5gC4S cqhmC 5gBNw 9Mg0Z 5gCiE 5gCiA 5gBNw 5gC3r 5gBNw 5gC3s 5gBNw 5gBxq 5gBNw 5gBNw 5gBNw 5gBNw 5gC2t 5gC32 5gBxS 5gBxG 5gBNw 5gC3C 7kgTs 5gBxr 5gBNw 5gCxH 5gC35 5gCyT 5gC3i 5gBxr 8PUmG 5gC3g 5gByw 5gBy8 ...
output:
000000000000111111111000000000000000000011100000000011000000000000000010000000000000000000000000000000000000000000000000000000000011111111000000000000000000001000000000001111111111111111000000000011100000000000000000000000000000000000000000000000000000000000000011000000000000000000000000000000000000...
result:
ok single line: '000000000000111111111000000000...0000000000000000010000000000000'
Test #18:
score: 0
Accepted
time: 18ms
memory: 22204kb
input:
90681 7ikvw 7ikKZ 7ikKZ 7il0N 6emPC 7ikKZ 7ikuV 7ikwH 7ikv6 7il01 7ikKZ 7ikvE 7ikZZ 7ikKZ 7ikKZ 7ikKZ 7il0P 6gk92 6IHCx 7ikvE 7ikKZ 7il10 4CEF3 7il0E 7ikvR 7il0K 7ikvD 5wN3T 7ikKZ 7VkIL 7ikuY 7ikKZ 7il0W 7ikv9 7ikw3 8q1jA 7ikuW 7il0S 7ikKZ 7ikKZ 4TBXj 7ikKZ 7ikwV 5sPvF 7il0X 7ikKZ 7il0M 7ikuY 7ikKZ ...
output:
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111111111111111100000000000011110000000000001111111111110011111000000000000000000000000000000000000000111110000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
ok single line: '000000000000000000000000000000...1111111111111111111110000000000'
Test #19:
score: -100
Wrong Answer
time: 140ms
memory: 40636kb
input:
1780451 8z83a 8z8za 8z8jd 8z8z9 8z8z9 8z8jd 8z8wQ 8z8yR 8z8jd 8z83d 8z8z3 8z8jd 8z8jd 8z8jd 8z83B 8z83m 8z8zj 8z8jd 8z8z6 8z8yi 8z83c 8z841 8z8jd 5mfGk 8z8yq 8z84J 8z849 8CSgj 8z8zf 8z83H 8z83Y 8WCue 8z83o 8z83g 8z8yy 8z8jd 8z84r 8z84g 8z8yK 8z8z2 8z8jd 8z836 4Lgz2 8z8yS 8z8jd 8z8jd 8z8z4 8z8jd 8z8j...
output:
000000000000000000000000000000000000000000000000000000000000000000111111111100000000000000000000000000000000000000000000000000000000000000000000000000001111111111111111111111111111111111111111111111111111111111111111111111111110000000000000000011111111110000000000000000000000000000000000000000000000...
result:
wrong answer 1st lines differ - expected: '000000000000000000000000000000...0000000000000000000000000000000', found: '000000000000000000000000000000...0000000000000000000000000000000'