QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#332958#7877. Balanced ArraywcyQwQWA 1ms5776kbC++141.4kb2024-02-19 16:41:152024-02-19 16:41:15

Judging History

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

  • [2024-02-19 16:41:15]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5776kb
  • [2024-02-19 16:41:15]
  • 提交

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)) {
            R++;
        }
        dt[2 * k + 1]++, dt[R + 1]--;
    }
    L(i, 1, n) {
        dt[i] += dt[i - 1];
        printf("%d ", !!dt[i]);
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 5776kb

input:

3
1 2 3

output:

0 0 1 

result:

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