mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-23 20:28:48 +00:00
Compare commits
3 Commits
e0ae2db0e2
...
3e05d6d6b5
Author | SHA1 | Date | |
---|---|---|---|
3e05d6d6b5 | |||
b5d6d5a0fc | |||
d8e347f8ab |
59
Luogu/P3622/P3622.cpp
Normal file
59
Luogu/P3622/P3622.cpp
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
const int N = 1e4 + 5,
|
||||||
|
C = 5e4 + 5,
|
||||||
|
M = (1 << 5) + 5;
|
||||||
|
|
||||||
|
int n, c, a[C][M], f[N][M], ans;
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
std::ios::sync_with_stdio(false);
|
||||||
|
cin.tie(nullptr);
|
||||||
|
|
||||||
|
cin >> n >> c;
|
||||||
|
|
||||||
|
for (int i = 1, e, f, l; i <= c; i++) {
|
||||||
|
cin >> e >> f >> l;
|
||||||
|
|
||||||
|
int fear = 0;
|
||||||
|
|
||||||
|
for (int j = 1, x; j <= f; j++) {
|
||||||
|
cin >> x;
|
||||||
|
|
||||||
|
fear |= (1 << (x - e + n) % n);
|
||||||
|
}
|
||||||
|
|
||||||
|
int like = 0;
|
||||||
|
|
||||||
|
for (int j = 1, y; j <= l; j++) {
|
||||||
|
cin >> y;
|
||||||
|
|
||||||
|
like |= (1 << (y - e + n) % n);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int j = 0; j < 1 << 5; j++) {
|
||||||
|
if ((like & j) || (fear & ~j)) a[e][j]++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int s = 0; s < 1 << 5; s++) {
|
||||||
|
std::fill_n(f[0], M, std::numeric_limits<int>::min());
|
||||||
|
f[0][s] = 0;
|
||||||
|
|
||||||
|
for (int i = 1; i <= n; i++) {
|
||||||
|
for (int j = 0; j < 1 << 5; j++) {
|
||||||
|
f[i][j] = max(f[i - 1][(j & 0b1111) << 1], f[i - 1][(j & 0b1111) << 1 | 1]) + a[i][j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ans = std::max(ans, f[n][s]);
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << ans << endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
83
Luogu/P4766/P4766.cpp
Normal file
83
Luogu/P4766/P4766.cpp
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <array>
|
||||||
|
#include <limits>
|
||||||
|
#include <tuple>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
using std::cin;
|
||||||
|
using std::cout;
|
||||||
|
const char endl = '\n';
|
||||||
|
|
||||||
|
const int N = 305;
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
std::ios::sync_with_stdio(false);
|
||||||
|
cin.tie(nullptr);
|
||||||
|
|
||||||
|
int t;
|
||||||
|
|
||||||
|
cin >> t;
|
||||||
|
|
||||||
|
while (t--) {
|
||||||
|
int n;
|
||||||
|
|
||||||
|
cin >> n;
|
||||||
|
|
||||||
|
std::vector<std::tuple<int, int, int>> data(n);
|
||||||
|
std::vector<int> nums;
|
||||||
|
|
||||||
|
for (auto& e : data) {
|
||||||
|
int a, b, d;
|
||||||
|
|
||||||
|
cin >> a >> b >> d;
|
||||||
|
|
||||||
|
e = std::make_tuple(a, b, d);
|
||||||
|
nums.emplace_back(a);
|
||||||
|
nums.emplace_back(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::sort(nums.begin(), nums.end());
|
||||||
|
nums.erase(std::unique(nums.begin(), nums.end()), nums.end());
|
||||||
|
|
||||||
|
for (auto& e : data) {
|
||||||
|
std::get<0>(e) = std::lower_bound(nums.begin(), nums.end(), std::get<0>(e)) - nums.begin() + 1;
|
||||||
|
std::get<1>(e) = std::lower_bound(nums.begin(), nums.end(), std::get<1>(e)) - nums.begin() + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int m = nums.size();
|
||||||
|
std::array<std::array<int, N << 1>, N << 1> f;
|
||||||
|
|
||||||
|
for (int len = 0; len < m; len++) {
|
||||||
|
for (int l = 1, r = 1 + len; r <= m; l++, r++) {
|
||||||
|
auto it = data.end();
|
||||||
|
|
||||||
|
for (auto _it = data.begin(); _it != data.end(); _it++) {
|
||||||
|
int a, b, d;
|
||||||
|
std::tie(a, b, d) = *_it;
|
||||||
|
|
||||||
|
if (l <= a && b <= r && (it == data.end() || d > std::get<2>(*it))) {
|
||||||
|
it = _it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (it == data.end()) {
|
||||||
|
f[l][r] = 0;
|
||||||
|
} else {
|
||||||
|
f[l][r] = std::numeric_limits<int>::max();
|
||||||
|
|
||||||
|
int a, b, d;
|
||||||
|
std::tie(a, b, d) = *it;
|
||||||
|
|
||||||
|
for (int i = a; i <= b; i++) {
|
||||||
|
f[l][r] = std::min(f[l][r], f[l][i - 1] + d + f[i + 1][r]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << f[1][m] << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
BIN
Luogu/P4766/data/P4766_1.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P4766/data/P4766_1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P4766/data/P4766_1.out
(Stored with Git LFS)
Normal file
BIN
Luogu/P4766/data/P4766_1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P4766/data/P4766_2.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P4766/data/P4766_2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P4766/data/P4766_2.out
(Stored with Git LFS)
Normal file
BIN
Luogu/P4766/data/P4766_2.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P4766/data/P4766_3.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P4766/data/P4766_3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P4766/data/P4766_3.out
(Stored with Git LFS)
Normal file
BIN
Luogu/P4766/data/P4766_3.out
(Stored with Git LFS)
Normal file
Binary file not shown.
38
S2OJ/1550/1550.cpp
Normal file
38
S2OJ/1550/1550.cpp
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
using std::cin;
|
||||||
|
using std::cout;
|
||||||
|
const char endl = '\n';
|
||||||
|
|
||||||
|
const int N = 1e5 + 5;
|
||||||
|
|
||||||
|
int n, a[N], c[N], p, ans;
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
std::ios::sync_with_stdio(false);
|
||||||
|
cin.tie(nullptr);
|
||||||
|
|
||||||
|
cin >> n;
|
||||||
|
|
||||||
|
bool flag = n >= 3;
|
||||||
|
|
||||||
|
for (int i = 1; i <= n; i++) {
|
||||||
|
cin >> a[i];
|
||||||
|
|
||||||
|
if (a[i] == n) p = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
flag &= a[1] == n - 1 && a[n] == n;
|
||||||
|
|
||||||
|
for (int i = 1; i < p; i++) {
|
||||||
|
if (a[i] > a[i + 1]) {
|
||||||
|
ans++;
|
||||||
|
std::swap(a[i], a[i + 1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << static_cast<long long>(n) * (n - 1) + ans - flag << endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
BIN
S2OJ/1550/data/bubble1.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1550/data/bubble1.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1550/data/bubble1.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1550/data/bubble1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1550/data/bubble10.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1550/data/bubble10.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1550/data/bubble10.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1550/data/bubble10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1550/data/bubble2.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1550/data/bubble2.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1550/data/bubble2.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1550/data/bubble2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1550/data/bubble3.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1550/data/bubble3.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1550/data/bubble3.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1550/data/bubble3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1550/data/bubble4.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1550/data/bubble4.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1550/data/bubble4.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1550/data/bubble4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1550/data/bubble5.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1550/data/bubble5.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1550/data/bubble5.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1550/data/bubble5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1550/data/bubble6.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1550/data/bubble6.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1550/data/bubble6.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1550/data/bubble6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1550/data/bubble7.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1550/data/bubble7.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1550/data/bubble7.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1550/data/bubble7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1550/data/bubble8.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1550/data/bubble8.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1550/data/bubble8.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1550/data/bubble8.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1550/data/bubble9.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1550/data/bubble9.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1550/data/bubble9.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1550/data/bubble9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1550/data/problem.conf
(Stored with Git LFS)
Normal file
BIN
S2OJ/1550/data/problem.conf
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user