mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-23 20:08:47 +00:00
1226. [SDOI2009]学校食堂Dining
https://hydro.ac/d/bzoj/record/6322ec6fbdf9bc31d160a0ae
This commit is contained in:
parent
e10acb110f
commit
686aaa9256
68
BZOJ/1226/1226.cpp
Normal file
68
BZOJ/1226/1226.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
BZOJ/1226/data/1.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/1.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/10.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/10.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/10.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/11.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/11.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/11.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/11.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/12.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/12.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/12.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/12.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/13.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/13.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/13.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/13.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/14.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/14.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/14.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/14.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/15.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/15.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/15.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/15.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/16.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/16.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/16.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/16.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/17.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/17.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/17.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/17.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/18.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/18.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/18.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/18.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/19.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/19.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/19.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/19.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/2.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/2.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/2.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/20.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/20.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/20.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/20.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/21.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/21.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/21.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/21.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/22.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/22.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/22.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/22.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/23.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/23.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/23.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/23.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/24.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/24.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/24.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/24.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/25.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/25.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/25.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/25.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/3.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/3.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/3.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/4.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/4.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/4.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/5.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/5.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/5.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/6.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/6.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/6.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/7.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/7.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/7.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/8.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/8.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/8.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/8.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/9.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/9.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/9.out
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user