QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#333764#7877. Balanced ArrayEasonLiangWA 1ms3824kbC++141.8kb2024-02-20 15:06:312024-02-20 15:06:31

Judging History

你现在查看的是最新测评结果

  • [2024-02-20 15:06:31]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3824kb
  • [2024-02-20 15:06:31]
  • 提交

answer

#include <bits/stdc++.h>
#define FileIO_(file) \
    freopen (file ".in", "r", stdin); \
    freopen (file ".out", "w", stdout);

using namespace std;

template<typename Tp>
inline void chmin (Tp &x, const Tp &y) { if (y < x) x = y; }
template<typename Tp>
inline void chmax (Tp &x, const Tp &y) { if (x < y) x = y; }

inline int toint (char c) {
    return
        islower (c) ? c - 'a' + 10 :
        isupper (c) ? c - 'A' + 36 : (c & 15);
}

template<typename Tp>
inline void read (Tp &x) {
    int c = getchar (); x = 0;
    while (!isgraph (c)) c = getchar ();
    do x = (x << 6) - (x << 1) + toint (c);
    while (isgraph (c = getchar ()));
}

typedef double dbl;
typedef long long ll;
typedef long double ldb;

void init () {}

const int maxn = 2e6 + 20;
const ll bx = 131;
const ll mod = 19260817;
int n, cnt[maxn];
ll px[maxn], hx[maxn];

ll pmod (ll x) {
    return x + (x >> 63 & mod);
}

ll getx (int p, int l) {
    return pmod (hx[p + l] - hx[p] * px[l] % mod);
}

bool check (int l, int k) {
    int len = l - 2 * k;
    return (getx (k, len) << 1) ==
        getx (0, len) + getx (k << 1, len);
}

void solve () {
    scanf ("%d", &n); px[0] = 1;

    for (int i = 1, a; i <= n; ++i) {
        read (a);
        px[i] = px[i - 1] * bx % mod;
        hx[i] = (hx[i - 1] * bx + a) % mod;
    }

    for (int k = 1, lo, hi, mid;
        (lo = k << 1 | 1) <= n; ++k) {
        ++cnt[lo]; hi = n + 1;
        while (lo < hi)
            if (check (mid = (lo + hi) >> 1, k))
                lo = mid + 1; else hi = mid;
        --cnt[lo];
    }

    for (int i = 1; i <= n; ++i)
        putchar ((cnt[i] += cnt[i - 1]) ? '1' : '0');
}

int main () {
//	#ifndef LSY
//	FileIO_("");
//	#endif
    int t = 1; init ();
//	scanf ("%d", &t);
    while (t--) solve ();
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3804kb

input:

3
1 2 3

output:

001

result:

ok single line: '001'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3752kb

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: 3756kb

input:

9
1C 3f 4S 3h 88 6x 4W d1 8c

output:

001010111

result:

ok single line: '001010111'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3580kb

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: 0ms
memory: 3800kb

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: 0ms
memory: 3824kb

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: 0ms
memory: 3616kb

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: -100
Wrong Answer
time: 0ms
memory: 3576kb

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:

0000000010101010111000001100000000001010001

result:

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