mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-27 13:56:26 +00:00
parent
e693723086
commit
bca32ea8ce
68
LibreOJ/3755/3755.cpp
Normal file
68
LibreOJ/3755/3755.cpp
Normal file
@ -0,0 +1,68 @@
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
const char endl = '\n';
|
||||
|
||||
const int N = 1005;
|
||||
const int INF = 0x3f3f3f3f;
|
||||
|
||||
int c, n, f[N][1 << 8][20];
|
||||
std::pair<int, int> a[N];
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
cin >> c;
|
||||
|
||||
while (c--) {
|
||||
memset(f, 0x3f, sizeof(f));
|
||||
|
||||
cin >> n;
|
||||
|
||||
for (int i = 1; i <= n; i++) {
|
||||
cin >> a[i].first >> a[i].second;
|
||||
}
|
||||
|
||||
f[1][0][7] = 0;
|
||||
for (int i = 1; i <= n; i++) {
|
||||
for (int j = 0; j < 1 << 8; j++) {
|
||||
for (int k = -8; k <= 7; k++) {
|
||||
if (f[i][j][k + 8] != INF) {
|
||||
if (j & 1) { // 当前同学吃了,无需考虑后方
|
||||
f[i + 1][j >> 1][k + 7] = std::min(f[i + 1][j >> 1][k + 7], f[i][j][k + 8]);
|
||||
} else {
|
||||
int t = INF;
|
||||
|
||||
for (int l = 0; l <= 7; l++) {
|
||||
if (j & 1 << l) continue;
|
||||
if (i + l > t) break;
|
||||
|
||||
if (i + l <= n) t = std::min(t, i + l + a[i + l].second);
|
||||
else t = std::min(t, i + l);
|
||||
|
||||
if (i + k) {
|
||||
int x = i + k <= n ? a[i + k].first : 0,
|
||||
y = i + l <= n ? a[i + l].first : 0;
|
||||
f[i][j | 1 << l][l + 8] = std::min(f[i][j | 1 << l][l + 8], f[i][j][k + 8] + (x ^ y));
|
||||
} else {
|
||||
f[i][j | 1 << l][l + 8] = std::min(f[i][j | 1 << l][l + 8], f[i][j][k + 8]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int ans = INF;
|
||||
for (int i = 0; i <= 8; i++) {
|
||||
ans = std::min(ans, f[n + 1][0][i]);
|
||||
}
|
||||
cout << ans << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
BIN
LibreOJ/3755/data/1.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/1.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/10.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/10.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/10.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/11.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/11.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/11.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/11.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/12.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/12.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/12.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/12.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/13.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/13.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/13.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/13.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/14.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/14.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/14.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/14.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/15.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/15.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/15.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/15.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/16.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/16.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/16.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/16.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/17.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/17.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/17.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/17.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/18.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/18.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/18.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/18.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/19.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/19.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/19.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/19.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/2.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/2.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/2.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/20.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/20.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/20.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/20.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/21.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/21.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/21.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/21.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/22.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/22.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/22.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/22.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/23.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/23.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/23.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/23.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/24.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/24.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/24.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/24.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/25.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/25.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/25.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/25.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/3.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/3.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/3.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/4.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/4.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/4.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/5.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/5.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/5.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/6.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/6.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/6.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/7.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/7.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/7.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/8.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/8.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/8.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/8.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/9.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/3755/data/9.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/3755/data/9.out
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user