mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-24 03:11:58 +00:00
parent
17c13ed975
commit
666a989ee6
50
S2OJ/1614/1614.cpp
Normal file
50
S2OJ/1614/1614.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
#include <iostream>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
const char endl = '\n';
|
||||
|
||||
const int K = 17;
|
||||
|
||||
int k, a[1 << K], b[1 << K], c[1 << K], f[K + 1][1 << K];
|
||||
|
||||
void dfs(int s, int d, int x) {
|
||||
int t = ((1 << k) - 1) ^ s;
|
||||
|
||||
for (int i = t;; i = (i - 1) & t) {
|
||||
if (d) f[d][i] = std::max(f[d - 1][i], f[d - 1][i | (1 << x)]);
|
||||
c[s | i] = std::max(c[s | i], f[d][i] + a[s]);
|
||||
if (!i) break;
|
||||
}
|
||||
|
||||
for (int i = x + 1; i < k; i++) {
|
||||
dfs(s | (1 << i), d + 1, i);
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
cin >> k;
|
||||
|
||||
for (int i = 0; i < 1 << k; i++) {
|
||||
cin >> a[i];
|
||||
}
|
||||
|
||||
for (int i = 0; i < 1 << k; i++) {
|
||||
cin >> b[i];
|
||||
|
||||
f[0][i] = b[i];
|
||||
}
|
||||
|
||||
dfs(0, 0, -1);
|
||||
|
||||
for (int i = 0; i < 1 << k; i++) {
|
||||
cout << c[i] << ' ';
|
||||
}
|
||||
|
||||
cout << endl;
|
||||
|
||||
return 0;
|
||||
}
|
BIN
S2OJ/1614/data/ex_ztl1.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1614/data/ex_ztl1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1614/data/ex_ztl1.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1614/data/ex_ztl1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1614/data/ex_ztl2.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1614/data/ex_ztl2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1614/data/ex_ztl2.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1614/data/ex_ztl2.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1614/data/problem.conf
(Stored with Git LFS)
Normal file
BIN
S2OJ/1614/data/problem.conf
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1614/data/ztl1.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1614/data/ztl1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1614/data/ztl1.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1614/data/ztl1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1614/data/ztl10.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1614/data/ztl10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1614/data/ztl10.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1614/data/ztl10.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1614/data/ztl2.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1614/data/ztl2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1614/data/ztl2.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1614/data/ztl2.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1614/data/ztl3.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1614/data/ztl3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1614/data/ztl3.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1614/data/ztl3.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1614/data/ztl4.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1614/data/ztl4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1614/data/ztl4.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1614/data/ztl4.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1614/data/ztl5.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1614/data/ztl5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1614/data/ztl5.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1614/data/ztl5.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1614/data/ztl6.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1614/data/ztl6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1614/data/ztl6.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1614/data/ztl6.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1614/data/ztl7.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1614/data/ztl7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1614/data/ztl7.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1614/data/ztl7.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1614/data/ztl8.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1614/data/ztl8.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1614/data/ztl8.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1614/data/ztl8.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1614/data/ztl9.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1614/data/ztl9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1614/data/ztl9.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1614/data/ztl9.out
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user