QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#332342#7877. Balanced ArrayTerdyWA 1ms7892kbC++141.2kb2024-02-19 14:37:102024-02-19 14:37:10

Judging History

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

  • [2024-02-19 14:37:10]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:7892kb
  • [2024-02-19 14:37:10]
  • 提交

answer

# include <bits/stdc++.h>

using namespace std;

# define ull unsigned long long 

const int N = 2e6 + 5 , base = 233 , mod = 1e9 + 7;
int n , a[N] , ans[N];
int ha[N] , pw[N*9];

int trans(string s)
{
    int res = 0;
    for(int i = 0; i < s.length(); i++)
    {
        if('0' <= s[i] && s[i] <= '9') res = res * 62 + s[i] - '0';
        if('a' <= s[i] && s[i] <= 'z') res = res * 62 + s[i] - 'a' + 10;
        if('A' <= s[i] && s[i] <= 'Z') res = res * 62 + s[i] - 'A' + 10 + 26;
    }
    return res;
}

ull Ha(int l , int r)
{
    return ha[r] - ha[l - 1] * pw[r - l + 1];
}

bool check(int k , int l)
{
    return Ha(1 , l - 2 * k) + Ha(2 * k + 1 , l) == 2 * Ha(k + 1 , l - k);
}

int main()
{
    cin >> n;
    pw[0] = 1;
    for(int i = 1; i <= 9 * n; i++) pw[i] = pw[i - 1] * base;
    for(int i = 1; i <= n; i++)
    {
        string s;
        cin >> s;
        a[i] = trans(s);
        ha[i] = ha[i - 1] * base + a[i];
    }
    for(int i = 1 , j = 1; i <= (n - 1) / 2 && j <= n; i++)
    {
        while(i > (j - 1) / 2) j++;
        while(check(i , j) && j <= n) ans[j] = 1 , j++;
    }
    for(int i = 1; i <= n; i++) cout << ans[i];
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
1 2 3

output:

001

result:

ok single line: '001'

Test #2:

score: 0
Accepted
time: 1ms
memory: 7692kb

input:

9
1 2 3 2 5 4 3 8 5

output:

001010111

result:

ok single line: '001010111'

Test #3:

score: 0
Accepted
time: 1ms
memory: 7608kb

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

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: 1ms
memory: 7696kb

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

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:

00100000000000001100001000001000100011101111000000

result:

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