QOJ.ac
QOJ
ID | Submission ID | Problem | Hacker | Owner | Result | Submit time | Judge time |
---|---|---|---|---|---|---|---|
#598 | #387296 | #8330. Count off 3 | marher | Mysterious_Cat | Success! | 2024-04-17 10:54:15 | 2024-04-17 10:54:15 |
Details
Extra Test:
Wrong Answer
time: 204ms
memory: 30704kb
input:
10 111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...
output:
124194923 124194923 124194923 124194923 124194923 124194923 124194923 124194923 124194923 1000000007
result:
wrong answer 10th numbers differ - expected: '0', found: '1000000007'
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#387296 | #8330. Count off 3 | Mysterious_Cat | WA | 128ms | 30816kb | C++17 | 4.2kb | 2024-04-12 12:06:07 | 2024-10-13 18:51:46 |
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 5;
const int mod = 1e9 + 7;
int n, ans, sum[4][2], pw[N][7], dp[N][7][7][7][2], f[5][5][5][2];
string s;
int m7(int x) {
x %= 7;
return min(x, 7 - x);
}
int main() {
ios::sync_with_stdio(0); cin.tie(0);
for (int j = 1; j <= 6; j++) {
pw[0][j] = 1;
}
dp[0][0][0][0][1] = 1;
dp[0][1][1][1][0] = 1;
for (int i = 1; i <= (int)1e4; i++) {
for (int j = 1; j <= 6; j++) {
pw[i][j] = 1ll * pw[i - 1][j] * j % 7;
}
for (int s1 = 0; s1 < 7; s1++) {
for (int s2 = 0; s2 < 7; s2++) {
for (int s3 = 0; s3 < 7; s3++) {
dp[i][s1][s2][s3][i & 1] = (dp[i - 1][s1][s2][s3][i & 1] + dp[i - 1][(s1 - pw[i][1] + 7) % 7][(s2 - pw[i][2] + 7) % 7][(s3 - pw[i][3] + 7) % 7][i & 1]) % mod;
dp[i][s1][s2][s3][i & 1 ^ 1] = dp[i - 1][s1][s2][s3][i & 1 ^ 1];
}
}
}
}
int T;
cin >> T;
while (T--) {
cin >> s;
n = s.size();
ans = 0;
reverse(s.begin(), s.end());
memset(sum, 0, sizeof(sum));
for (int i = n - 1; i >= 0; i--) {
if (s[i] == '1') {
if (i > 0) {
memset(f, 0, sizeof(f));
for (int s1 = 0; s1 < 7; s1++) {
for (int s2 = 0; s2 < 7; s2++) {
for (int s3 = 0; s3 < 7; s3++) {
f[m7(s1 + sum[1][0])][m7(s2 + sum[2][0])][m7(s3 + sum[3][0])][0] = (f[m7(s1 + sum[1][0])][m7(s2 + sum[2][0])][m7(s3 + sum[3][0])][0] + dp[i - 1][s1][s2][s3][0]) % mod;
f[m7(s1 + sum[1][1])][m7(s2 + sum[2][1])][m7(s3 + sum[3][1])][1] = (f[m7(s1 + sum[1][1])][m7(s2 + sum[2][1])][m7(s3 + sum[3][1])][1] + dp[i - 1][s1][s2][s3][1]) % mod;
}
}
}
for (int t1 = 0; t1 < 4; t1++) {
for (int t2 = 0; t2 <= 4; t2++) {
for (int t3 = 0; t3 <= 4; t3++) {
f[4][t2][t3][0] = (f[4][t2][t3][0] + f[t1][t2][t3][0]) % mod;
f[4][t2][t3][1] = (f[4][t2][t3][1] + f[t1][t2][t3][1]) % mod;
}
}
}
for (int t1 = 0; t1 <= 4; t1++) {
for (int t2 = 0; t2 < 4; t2++) {
for (int t3 = 0; t3 <= 4; t3++) {
f[t1][4][t3][0] = (f[t1][4][t3][0] + f[t1][t2][t3][0]) % mod;
f[t1][4][t3][1] = (f[t1][4][t3][1] + f[t1][t2][t3][1]) % mod;
}
}
}
for (int t1 = 0; t1 <= 4; t1++) {
for (int t2 = 0; t2 <= 4; t2++) {
for (int t3 = 0; t3 < 4; t3++) {
f[t1][t2][4][0] = (f[t1][t2][4][0] + f[t1][t2][t3][0]) % mod;
f[t1][t2][4][1] = (f[t1][t2][4][1] + f[t1][t2][t3][1]) % mod;
}
}
}
for (int t1 = 0; t1 <= 4; t1++) {
for (int t2 = 0; t2 <= 4; t2++) {
for (int t3 = 0; t3 <= 4; t3++) {
ans = ((ans + ((t1 < 4) + (t2 < 4) + (t3 < 4) & 1 ? -1ll : 1ll) * f[t1][t2][t3][0] * f[t1][t2][t3][1] % mod) % mod + mod) % mod;
}
}
}
}
for (int j = 1; j <= 3; j++) {
sum[j][i & 1] = (sum[j][i & 1] + pw[i][j]) % 7;
}
if (i == 0) {
bool flag = 1;
for (int j = 1; j <= 3; j++) {
flag &= (sum[j][0] + sum[j][1]) % 7 && (sum[j][0] - sum[j][1] + 7) % 7;
}
ans += flag;
}
}
}
cout << ans << '\n';
}
return 0;
}