QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#712565 | #9562. 欧伊昔 | hos_lyric# | 55 | 657ms | 70244kb | C++14 | 4.4kb | 2024-11-05 16:10:52 | 2024-11-05 16:10:52 |
Judging History
answer
#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>
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;
vector<int> A, B;
int P[4], Q[4], S[3][4];
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);
THR[0] = 1;
for (int i = 1; i <= N; ++i) THR[i] = THR[i - 1] * 3;
A.resize(THR[N]); for (int h = 0; h < THR[N]; ++h) scanf("%d", &A[h]);
B.resize(THR[N]); for (int h = 0; h < THR[N]; ++h) scanf("%d", &B[h]);
for (int r1 = 0; r1 < 48; ++r1) for (int r2 = 0; r2 < r1; ++r2) for (int r3 = 0; r3 < r2; ++r3) {
const int rs[4] = {48, r1, r2, r3};
for (int k = 0; k < 4; ++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) {
const int ss[4] = {s0, s1, s2, s3};
int coef[3][3] = {};
for (int k = 0; k < 4; ++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 (ok) {
oks[z] = true;
copy(ss, ss + 4, S[z]);
}
}
}
#undef reps
if (oks[0] && oks[1] && oks[2]) {
goto found;
}
}
cerr<<"not found"<<endl;
assert(false);
found:{}
cerr<<"P = ";pv(P,P+4);
cerr<<"Q = ";pv(Q,Q+4);
for(int z=0;z<3;++z){cerr<<"S["<<z<<"] = ";pv(S[z],S[z]+4);}
vector<Int> as(1 << (2*N), 0), bs(1 << (2*N), 0);
for (int h = 0; h < THR[N]; ++h) {
int hh = 0;
for (int i = 0; i < N; ++i) hh |= (h / THR[i] % 3) << (2*i);
as[hh] = A[h];
bs[hh] = B[h];
}
for (int i = 0; i < N; ++i) {
for (int h = 0; h < 1 << (2*N); ++h) if (!(h >> (2*i) & 3)) {
Int tmp[4] = {};
for (int k = 0; k < 4; ++k) for (int x = 0; x < 3; ++x) if (P[k] >> x & 1) tmp[k] += as[h | x << (2*i)];
for (int k = 0; k < 4; ++k) as[h | k << (2*i)] = tmp[k];
}
}
for (int i = 0; i < N; ++i) {
for (int h = 0; h < 1 << (2*N); ++h) if (!(h >> (2*i) & 3)) {
Int tmp[4] = {};
for (int k = 0; k < 4; ++k) for (int x = 0; x < 3; ++x) if (Q[k] >> x & 1) tmp[k] += bs[h | x << (2*i)];
for (int k = 0; k < 4; ++k) bs[h | k << (2*i)] = tmp[k];
}
}
for (int h = 0; h < 1 << (2*N); ++h) as[h] *= bs[h];
for (int i = 0; i < N; ++i) {
for (int h = 0; h < 1 << (2*N); ++h) if (!(h >> (2*i) & 3)) {
Int tmp[4] = {};
for (int z = 0; z < 3; ++z) for (int k = 0; k < 4; ++k) tmp[z] += S[z][k] * as[h | k << (2*i)];
for (int z = 0; z < 4; ++z) as[h | z << (2*i)] = tmp[z];
}
}
for (int h = 0; h < THR[N]; ++h) {
int hh = 0;
for (int i = 0; i < N; ++i) hh |= (h / THR[i] % 3) << (2*i);
if (h) printf(" ");
printf("%lld", as[hh]);
}
puts("");
}
return 0;
}
詳細信息
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: 51ms
memory: 4052kb
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: 53ms
memory: 4080kb
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: 52ms
memory: 3920kb
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: 80ms
memory: 7368kb
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: 657ms
memory: 70088kb
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: 1ms
memory: 3828kb
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: 10ms
memory: 3784kb
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: 2ms
memory: 3916kb
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: 37ms
memory: 7448kb
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: 613ms
memory: 70244kb
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: 30
Accepted
Test #16:
score: 30
Accepted
time: 7ms
memory: 4080kb
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: 6ms
memory: 3780kb
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: 30
Accepted
time: 9ms
memory: 4116kb
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:
322011 265965 0 260223 215956 0 0 0 0 263733 211227 0 215511 174371 0 0 0 0 0 0 0 0 0 0 0 0 0 266760 215095 0 211273 172309 0 0 0 0 214580 167887 0 173403 135852 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 253574 204516 0 204277 166421 0 0 0 0 207948 162851 0 1729...
result:
ok single line: '322011 265965 0 260223 215956 ...0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0'
Test #19:
score: 30
Accepted
time: 42ms
memory: 7464kb
input:
0 0 0 1 0 1 1 0 1 9 4 2 6 7 4 0 9 7 7 1 6 0 1 4 4 6 7 0 8 4 1 3 2 2 0 6 6 8 9 7 0 3 8 9 4 1 8 6 5 7 5 4 2 8 3 7 9 6 1 7 5 2 9 2 7 9 7 1 2 1 3 4 4 7 0 7 3 9 7 6 5 3 8 7 0 4 6 2 7 4 0 6 0 4 4 1 2 0 7 4 2 2 4 6 8 0 3 2 2 1 8 7 7 7 8 3 2 4 6 4 4 8 2 4 6 5 0 0 1 7 5 0 6 7 3 4 4 3 5 6 8 1 9 2 5 1 6 0 6 5 ...
output:
40385937 31934762 0 31782968 25077003 0 0 0 0 31023309 24888805 0 23789431 19681164 0 0 0 0 0 0 0 0 0 0 0 0 0 31987079 25546274 0 25044943 19461021 0 0 0 0 25039688 19751368 0 19460419 15885046 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 30628498 25280629 0 245971...
result:
ok single line: '40385937 31934762 0 31782968 2...0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0'
Test #20:
score: 30
Accepted
time: 617ms
memory: 70180kb
input:
1 0 1 0 1 1 0 1 1 11 1 2 3 9 6 4 9 3 8 9 5 9 4 3 3 2 9 6 1 8 0 4 2 5 2 0 7 6 8 0 1 7 9 7 2 8 7 2 4 5 3 1 6 7 8 9 5 2 2 2 7 5 2 6 9 1 5 1 9 4 9 6 0 3 6 2 1 1 0 7 7 8 0 8 7 6 7 9 3 7 8 7 3 3 0 5 9 1 7 3 5 4 3 3 1 1 6 4 2 7 4 1 4 3 4 7 0 7 2 5 6 9 5 9 1 6 4 9 6 9 7 9 2 2 5 3 7 3 7 5 9 8 9 7 1 7 7 6 0 2...
output:
3330757 6904276 0 6996758 14294336 0 0 0 0 7094512 14150626 0 14703887 29236909 0 0 0 0 0 0 0 0 0 0 0 0 0 6778135 14131886 0 14023801 28519549 0 0 0 0 14162278 28291932 0 28809996 57166032 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 7085904 14086903 0 14087635 278...
result:
ok single line: '3330757 6904276 0 6996758 1429...0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0'
Subtask #5:
score: 0
Runtime Error
Test #21:
score: 10
Accepted
time: 37ms
memory: 7480kb
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%