QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#269282 | #7877. Balanced Array | ucup-team1453# | WA | 1ms | 5664kb | C++11 | 1.6kb | 2023-11-29 14:44:22 | 2023-11-29 14:44:23 |
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)
#define ll long long
#define vi vector <int>
#define sz(a) ((int) (a).size())
#define me(f, x) memset(f, x, sizeof(f))
#define uint unsigned int
#define ull unsigned long long
#define i128 __int128
using namespace std;
const int mod = 1019260817, G = 19491001;
const int N = 2e6 + 7;
int n;
int a[N];
int pw[N];
int pre[N];
inline int Get(int l, int Len) {
int r = l + Len - 1;
return (pre[r] - (ll)pre[l - 1] * pw[r - l + 1] % mod) % mod;
}
int ans[N];
int main() {
// freopen("data.txt", "r", stdin);
ios :: sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin >> n;
L(i, 1, n) {
string s;
cin >> s;
for(auto&u : s) {
int w = 0;
if('0' <= u && u <= '9') {
w = u - '0';
} else if('a' <= u && u <= 'z') {
w = u - 'a' + 10;
} else if('A' <= u && u <= 'Z') {
w = u - 'A' + 36;
}
a[i] = a[i] * 62 + w;
}
}
L(i, 1, n) {
pre[i] = ((ll)pre[i - 1] * G + a[i]) % mod;
}
pw[0] = 1;
L(i, 1, n) {
pw[i] = (ll)pw[i - 1] * G % mod;
}
int mxp = 1;
for(int k = 1; k <= n; ++k) {
mxp = max(mxp, 2 * k + 1);
if(mxp > n) continue;
int len = mxp - 2 * k;
// cout << Get(1, len) << ' ' << Get(1 + k * 2, len) << ' ' << Get(1 + k, len) << endl;
if((Get(1, len) + Get(1 + k * 2, len)) % mod == (ll)2 * Get(1 + k, len) % mod) {
while(a[mxp] + a[mxp - 2 * k] == a[mxp - k] * 2) {
ans[mxp] = 1;
++mxp;
}
}
}
L(i, 1, n)
cout << ans[i];
cout << '\n';
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 5576kb
input:
3 1 2 3
output:
001
result:
ok single line: '001'
Test #2:
score: 0
Accepted
time: 1ms
memory: 5644kb
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: 5608kb
input:
9 1C 3f 4S 3h 88 6x 4W d1 8c
output:
001010111
result:
ok single line: '001010111'
Test #4:
score: -100
Wrong Answer
time: 1ms
memory: 5664kb
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:
0000111111001000000000001000000000110000100000000
result:
wrong answer 1st lines differ - expected: '0000111111001000000000001000000000110000100000001', found: '0000111111001000000000001000000000110000100000000'