QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#712812 | #9562. 欧伊昔 | hos_lyric# | 25 | 1338ms | 767816kb | C++14 | 5.2kb | 2024-11-05 17:08:13 | 2024-11-05 17:08:14 |
Judging History
answer
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#pragma GCC target("avx2")
using namespace std;
using Int = long long;
template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }
#define COLOR(s) ("\x1b[" s "m")
int OP[3][3];
int N;
vector<int> THR, FIV;
vector<int> A, B;
int P[5], Q[5], S[3][5];
vector<int> as, bs;
vector<Int> cs;
void rec(int i, int h0) {
if (i) {
--i;
for (int h = h0; h < h0 + FIV[i]; ++h) {
int tmp[5] = {};
// for (int k = 0; k < 5; ++k) for (int x = 0; x < 3; ++x) if (P[k] >> x & 1) tmp[k] += as[h + x * FIV[i]];
for (int x = 0; x < 3; ++x) {
const int a = as[h + x * FIV[i]];
if (a) {
for (int k = 0; k < 5; ++k) if (P[k] >> x & 1) tmp[k] += a;
}
}
for (int k = 0; k < 5; ++k) as[h + k * FIV[i]] = tmp[k];
}
for (int h = h0; h < h0 + FIV[i]; ++h) {
int tmp[5] = {};
// for (int k = 0; k < 5; ++k) for (int y = 0; y < 3; ++y) if (Q[k] >> y & 1) tmp[k] += bs[h + y * FIV[i]];
for (int y = 0; y < 3; ++y) {
const int b = bs[h + y * FIV[i]];
if (b) {
for (int k = 0; k < 5; ++k) if (Q[k] >> y & 1) tmp[k] += b;
}
}
for (int k = 0; k < 5; ++k) bs[h + k * FIV[i]] = tmp[k];
}
for (int k = 0; k < 5; ++k) {
rec(i, h0 + k * FIV[i]);
}
for (int h = h0; h < h0 + FIV[i]; ++h) {
Int tmp[5] = {};
for (int z = 0; z < 3; ++z) for (int k = 0; k < 5; ++k) tmp[z] += S[z][k] * cs[h + k * FIV[i]];
for (int z = 0; z < 5; ++z) cs[h + z * FIV[i]] = tmp[z];
}
} else {
cs[h0] = (Int)as[h0] * bs[h0];
}
}
int main() {
for (; ; ) {
for (int x = 0; x < 3; ++x) for (int y = 0; y < 3; ++y) {
if (!~scanf("%d", &OP[x][y])) return 0;
}
scanf("%d", &N);
THR.resize(N + 1);
FIV.resize(N + 1);
THR[0] = 1;
FIV[0] = 1;
for (int i = 1; i <= N; ++i) THR[i] = THR[i - 1] * 3;
for (int i = 1; i <= N; ++i) FIV[i] = FIV[i - 1] * 5;
A.resize(THR[N]); for (int g = 0; g < THR[N]; ++g) scanf("%d", &A[g]);
B.resize(THR[N]); for (int g = 0; g < THR[N]; ++g) scanf("%d", &B[g]);
for (int r1 = 0; r1 < 48; ++r1) for (int r2 = 0; r2 < r1; ++r2) for (int r3 = 0; r3 < r2; ++r3) for (int r4 = 0; r4 < r3; ++r4) {
const int rs[5] = {48, r1, r2, r3, r4};
for (int k = 0; k < 5; ++k) {
P[k] = 1 + rs[k] / 7;
Q[k] = 1 + rs[k] % 7;
}
bool oks[3] = {};
#define reps(s) for (int s = -1; s <= +1; ++s)
reps(s0) reps(s1) reps(s2) reps(s3) reps(s4) {
const int ss[5] = {s0, s1, s2, s3, s4};
int coef[3][3] = {};
for (int k = 0; k < 5; ++k) {
for (int x = 0; x < 3; ++x) if (P[k] >> x & 1)
for (int y = 0; y < 3; ++y) if (Q[k] >> y & 1)
{
coef[x][y] += ss[k];
}
}
for (int z = 0; z < 3; ++z) {
bool ok = true;
for (int x = 0; x < 3; ++x) for (int y = 0; y < 3; ++y) {
// ok = ok && (coef[x][y] == ((OP[x][y] == z) ? 1 : 0));
if (!(coef[x][y] == ((OP[x][y] == z) ? 1 : 0))) { ok = false; break; }
}
if (ok) {
oks[z] = true;
copy(ss, ss + 5, S[z]);
}
if (!oks[z]) break;
}
}
#undef reps
if (oks[0] && oks[1] && oks[2]) {
goto found;
}
}
cerr<<"not found"<<endl;
assert(false);
found:{}
cerr<<"P = ";pv(P,P+5);
cerr<<"Q = ";pv(Q,Q+5);
for(int z=0;z<3;++z){cerr<<"S["<<z<<"] = ";pv(S[z],S[z]+5);}
as.assign(FIV[N], 0);
bs.assign(FIV[N], 0);
cs.assign(FIV[N], 0);
for (int g = 0; g < THR[N]; ++g) {
int h = 0;
for (int i = 0; i < N; ++i) h += (g / THR[i] % 3) * FIV[i];
as[h] = A[g];
bs[h] = B[g];
}
rec(N, 0);
for (int g = 0; g < THR[N]; ++g) {
int h = 0;
for (int i = 0; i < N; ++i) h += (g / THR[i] % 3) * FIV[i];
if (g) printf(" ");
printf("%lld", cs[h]);
}
puts("");
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Runtime Error
Test #1:
score: 0
Runtime Error
input:
0 1 2 1 2 0 2 0 1 1 7 1 5 8 4 5
output:
result:
Subtask #2:
score: 5
Accepted
Test #6:
score: 5
Accepted
time: 66ms
memory: 3912kb
input:
1 2 1 2 0 0 1 0 0 1 8 9 3 1 6 1
output:
84 19 57
result:
ok single line: '84 19 57'
Test #7:
score: 5
Accepted
time: 66ms
memory: 3768kb
input:
1 2 1 2 0 0 1 0 0 3 0 9 8 8 9 2 6 5 1 7 2 9 8 8 7 9 1 9 8 0 3 6 8 6 6 1 6 2 7 1 0 3 4 9 1 7 3 1 3 3 6 1 4 6 7 3 9 5 0 6 5 6 6 8
output:
2070 1350 930 936 1077 524 774 445 422 995 939 563 984 446 409 681 160 255 715 715 415 569 372 227 360 144 155
result:
ok single line: '2070 1350 930 936 1077 524 774...715 415 569 372 227 360 144 155'
Test #8:
score: 5
Accepted
time: 66ms
memory: 4072kb
input:
1 2 1 2 0 0 1 0 0 6 4 6 7 3 1 5 3 4 8 5 8 4 8 2 5 9 5 8 9 9 5 0 1 3 3 6 2 6 2 0 7 4 1 9 3 0 1 4 7 6 3 5 6 6 6 8 5 4 7 6 5 6 0 9 3 3 7 7 5 3 2 8 8 6 6 7 5 1 5 0 4 0 6 4 4 0 8 8 9 7 2 3 9 1 2 7 7 5 9 4 2 0 4 0 7 3 2 0 0 5 7 3 0 3 1 4 7 1 5 0 5 7 0 7 3 3 3 0 4 4 8 3 0 3 5 4 6 4 6 2 5 2 6 0 1 0 3 2 7 2 ...
output:
83790 80087 47498 54766 53378 30734 37004 38711 20149 56840 51419 30908 44535 34931 19224 28930 21902 13476 40400 35311 23275 29138 24090 14354 18657 16767 10404 54800 54365 26409 41788 36518 23297 26116 26545 15046 43022 40283 20072 32970 27617 15595 19273 21888 11540 29066 27596 14097 20358 17763 ...
result:
ok single line: '83790 80087 47498 54766 53378 ...2 3398 2919 2036 2020 2095 1314'
Test #9:
score: 5
Accepted
time: 112ms
memory: 33820kb
input:
1 2 1 2 0 0 1 0 0 9 1 4 5 7 9 9 3 2 8 2 1 9 6 3 7 1 5 1 8 5 5 2 2 6 4 0 2 2 4 5 5 6 1 0 4 3 4 6 8 5 9 6 5 0 6 3 9 9 6 0 3 0 9 8 4 8 5 2 6 2 3 7 6 1 6 0 0 0 6 9 1 5 1 1 6 9 3 0 1 6 3 9 9 4 1 6 7 6 1 9 4 8 3 7 5 6 7 7 4 2 1 8 0 2 0 1 4 9 6 1 3 9 3 9 1 7 6 3 5 1 2 9 5 9 1 9 0 2 6 8 0 3 2 3 3 8 7 5 7 5 ...
output:
5491236 3870726 2722667 4095376 3095055 2071305 2714963 2074656 1399744 4044155 3120903 2064947 3040305 2366779 1542749 2083106 1574507 1033341 2685025 2000208 1380383 2078336 1610975 1031792 1345673 1054928 715576 4117744 2722921 1889883 3038009 1917155 1380031 2125417 1319541 942766 2939040 204967...
result:
ok single line: '5491236 3870726 2722667 409537...28 22661 14107 20702 15112 9567'
Test #10:
score: 5
Accepted
time: 1338ms
memory: 767816kb
input:
1 2 1 2 0 0 1 0 0 11 7 0 4 5 4 2 8 0 5 2 6 3 3 3 7 4 9 1 2 5 3 2 2 4 9 2 3 4 2 6 6 4 7 8 5 4 0 2 1 1 2 2 6 3 6 5 6 8 3 9 3 4 5 0 6 7 1 9 3 7 9 2 6 8 8 2 4 6 4 1 8 9 2 7 7 8 4 3 8 8 9 3 8 8 8 0 2 0 1 8 8 4 5 6 8 8 8 3 4 0 2 7 6 5 0 8 8 0 5 1 9 7 2 4 4 9 5 8 8 7 3 7 3 4 0 1 8 6 5 5 9 0 0 6 3 7 1 3 5 3...
output:
86479708 63720192 41859212 65499632 45056892 30743097 43125563 31086911 20505561 62406595 47201203 31455187 48665387 34840892 23780593 31386819 23538226 15647083 41894617 31577694 20829302 32537059 22546949 15608457 21012850 15484091 10337868 62979540 46676543 31353425 48890707 34173423 23561609 319...
result:
ok single line: '86479708 63720192 41859212 654...3 93847 60903 84153 63837 41857'
Subtask #3:
score: 20
Accepted
Test #11:
score: 20
Accepted
time: 46ms
memory: 3900kb
input:
1 1 1 0 0 0 1 1 1 1 6 2 1 3 1 5
output:
18 63 0
result:
ok single line: '18 63 0'
Test #12:
score: 20
Accepted
time: 244ms
memory: 3776kb
input:
1 1 0 0 0 1 0 0 1 3 4 6 4 5 6 8 7 7 4 0 0 9 1 0 9 0 8 5 3 4 0 0 4 2 3 5 1 4 2 5 5 6 2 4 6 5 2 5 0 0 4 0 6 3 8 1 2 3 7 0 6 8 4 8
output:
1776 1049 0 1615 1167 0 0 0 0 1582 1203 0 1536 1202 0 0 0 0 0 0 0 0 0 0 0 0 0
result:
ok single line: '1776 1049 0 1615 1167 0 0 0 0 ... 1202 0 0 0 0 0 0 0 0 0 0 0 0 0'
Test #13:
score: 20
Accepted
time: 66ms
memory: 4040kb
input:
1 1 1 1 1 1 0 0 0 6 8 7 3 9 0 9 3 3 8 3 2 4 9 8 4 1 2 9 0 3 1 8 7 9 9 4 0 4 6 6 7 2 2 1 4 4 4 3 6 7 8 0 2 7 4 9 8 6 2 9 9 8 3 7 6 4 1 2 2 0 3 0 3 9 8 5 9 3 5 6 4 1 9 6 3 2 9 4 9 2 7 5 0 3 0 2 7 5 4 5 6 1 9 3 7 2 6 3 2 3 5 3 3 0 8 1 4 0 1 1 4 5 0 0 2 1 8 3 6 6 3 0 1 9 3 4 9 2 7 1 2 8 5 1 4 3 4 9 8 5 ...
output:
12752 31880 0 31880 41444 0 0 0 0 38256 76512 0 54196 117956 0 0 0 0 0 0 0 0 0 0 0 0 0 38256 76512 0 66948 143460 0 0 0 0 51008 98828 0 191280 210408 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 38256 70136 0 63760 102016 0 0 0 0 79700 111580 0 105204 219972 0 0 0 ...
result:
ok single line: '12752 31880 0 31880 41444 0 0 ...0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0'
Test #14:
score: 20
Accepted
time: 86ms
memory: 34260kb
input:
0 0 1 0 0 1 0 0 1 9 3 5 7 4 5 0 9 0 8 1 6 7 7 2 6 3 2 9 8 2 8 1 5 2 0 0 1 0 6 5 8 6 9 3 2 1 8 3 0 9 2 9 0 2 6 0 0 4 0 6 2 7 8 7 9 8 8 8 4 5 1 1 8 3 1 1 6 2 6 9 4 9 2 9 4 7 3 7 0 8 3 3 1 5 8 8 6 3 5 3 9 6 1 8 1 7 4 6 4 7 1 8 4 1 3 3 3 3 0 7 5 5 2 4 0 0 9 7 2 6 0 9 0 9 6 3 0 5 0 8 3 4 3 0 3 4 8 5 9 6 ...
output:
203913878 109813438 0 98983010 49535892 0 0 0 0 102800292 53353174 0 55217428 20418020 0 0 0 0 0 0 0 0 0 0 0 0 0 107949184 50068536 0 53708270 24324076 0 0 0 0 56549038 23791432 0 27963810 13316100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 99071784 48115508 0 49...
result:
ok single line: '203913878 109813438 0 98983010...0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0'
Test #15:
score: 20
Accepted
time: 1320ms
memory: 767488kb
input:
0 0 0 0 0 0 0 0 0 11 4 2 4 1 1 1 9 6 0 9 2 5 4 0 4 7 7 3 5 4 2 4 3 7 1 2 4 6 7 0 1 1 4 4 1 2 9 3 9 5 0 1 9 8 7 8 9 0 9 8 4 2 8 8 4 2 2 0 8 7 7 9 7 8 6 8 7 7 8 1 6 2 4 3 9 3 9 9 2 7 0 7 2 3 7 5 9 5 2 1 6 3 3 0 8 4 2 8 3 7 2 5 4 9 8 4 5 1 3 7 5 1 4 3 8 8 4 3 3 6 9 5 4 8 5 1 7 1 9 0 5 7 8 0 6 5 5 2 7 9...
output:
635411468335 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
result:
ok single line: '635411468335 0 0 0 0 0 0 0 0 0...0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0'
Subtask #4:
score: 0
Runtime Error
Test #16:
score: 30
Accepted
time: 65ms
memory: 3888kb
input:
1 1 1 0 0 1 1 1 0 1 1 0 9 8 1 9
output:
81 99 0
result:
ok single line: '81 99 0'
Test #17:
score: 30
Accepted
time: 64ms
memory: 3844kb
input:
0 0 1 0 0 1 1 1 0 3 7 6 2 7 7 9 5 5 6 0 5 7 5 8 1 0 6 0 9 3 3 5 1 8 2 2 1 8 5 9 1 0 0 0 4 9 1 4 3 2 5 1 9 2 2 8 7 6 8 7 3 9 1 0
output:
2402 1847 0 1687 1320 0 0 0 0 2363 1614 0 1492 955 0 0 0 0 0 0 0 0 0 0 0 0 0
result:
ok single line: '2402 1847 0 1687 1320 0 0 0 0 ...2 955 0 0 0 0 0 0 0 0 0 0 0 0 0'
Test #18:
score: 0
Runtime Error
input:
1 0 0 0 1 0 1 0 1 6 4 6 4 1 9 6 7 6 7 5 0 7 4 1 5 7 5 7 4 7 9 7 6 3 3 8 5 4 4 0 8 8 9 2 8 3 5 9 3 1 4 1 1 5 7 7 7 5 7 4 9 8 1 0 7 9 3 8 4 8 2 9 5 3 4 0 5 3 8 2 7 8 8 7 4 8 5 2 4 2 1 0 6 1 7 0 1 2 9 8 3 5 9 9 0 1 6 3 9 7 0 1 9 8 4 4 4 3 1 4 5 4 4 6 2 2 7 2 6 5 8 5 4 5 9 7 4 1 7 1 3 2 6 3 6 0 0 5 9 6 ...
output:
result:
Subtask #5:
score: 0
Runtime Error
Test #21:
score: 10
Accepted
time: 101ms
memory: 33828kb
input:
0 2 2 1 1 1 0 1 1 9 2 7 2 7 4 5 9 7 9 6 8 4 0 6 3 3 6 3 0 5 2 3 7 6 7 8 3 6 1 1 6 9 9 2 7 2 1 2 8 2 9 3 5 0 5 7 1 2 3 1 4 8 0 4 3 4 2 8 8 4 2 9 3 7 1 1 6 6 4 0 9 6 5 8 8 1 3 8 7 3 0 4 3 8 7 0 0 7 6 4 3 6 0 2 3 3 6 5 0 5 9 8 6 1 0 4 7 8 2 4 7 4 8 6 9 6 3 5 1 8 0 1 4 7 0 0 1 2 7 7 0 5 5 3 8 2 7 8 9 8 ...
output:
18440 36200 13740 21447 61214 26652 5665 22043 8496 29112 57852 21456 67960 192140 70368 29748 86008 35360 8912 17724 6564 29955 76168 32916 11361 32499 12720 18364 76188 36444 42131 187672 92455 14190 70759 31583 70268 162402 69612 200033 446344 181086 87111 192351 80214 28253 57785 24432 98560 188...
result:
ok single line: '18440 36200 13740 21447 61214 ...176 81555 44223 4512 28578 4596'
Test #22:
score: 0
Runtime Error
input:
0 1 2 1 0 0 1 0 1 1 0 9 2 9 7 1
output:
result:
Subtask #6:
score: 0
Skipped
Dependency #5:
0%
Subtask #7:
score: 0
Skipped
Dependency #6:
0%