0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-09-19 15:45:26 +00:00

Compare commits

...

18 Commits

Author SHA1 Message Date
3256f5c172
1391. [Ceoi2008]order
https://hydro.ac/d/bzoj/record/6322c9dabdf9bc31d1607e4d
2022-09-15 14:44:58 +08:00
b1f483a26d
3540. [Usaco2014 Open]Fair Photography
https://hydro.ac/d/bzoj/record/6322c4e1bdf9bc31d1607974
2022-09-15 14:23:54 +08:00
39e04e9b16
3942. [Usaco2015 Feb]Censoring
https://hydro.ac/d/bzoj/record/6322c3ee32ae6c3198cc6e69
2022-09-15 14:19:31 +08:00
9c13898a05
4048. [Cerc2014] Outer space invaders
https://hydro.ac/d/bzoj/record/6322c25b32ae6c3198cc6c86
2022-09-15 14:13:27 +08:00
8f07b5e70f
1098. [POI2007]办公楼biu
https://hydro.ac/d/bzoj/record/6322c18cbdf9bc31d1607532
2022-09-15 14:09:21 +08:00
4a3a25865d
3007. 拯救小云公主
https://hydro.ac/d/bzoj/record/6322c13a32ae6c3198cc6b28
2022-09-15 14:07:57 +08:00
a3280eb4f0
3824. [Usaco2014 Dec]Guard Mark
https://hydro.ac/d/bzoj/record/6322c0dbbdf9bc31d1607432
2022-09-15 14:06:43 +08:00
6da142d5f8
3062. [Usaco2013 Feb]Taxi
https://hydro.ac/d/bzoj/record/6322c07fbdf9bc31d160737e
2022-09-15 14:05:14 +08:00
32ca556536
3613. [Heoi2014] 南园满地堆轻絮
https://hydro.ac/d/bzoj/record/6322c03f32ae6c3198cc6a1d
2022-09-15 14:04:06 +08:00
78a6e72b66
1833. [ZJOI2010] count 数字计数
https://hydro.ac/d/bzoj/record/6322bfef32ae6c3198cc69d5
2022-09-15 14:02:46 +08:00
0ef4b0e96c
1827. [Usaco2010 Mar]gather 奶牛大集会
https://hydro.ac/d/bzoj/record/6322ae5fbdf9bc31d1606279
2022-09-15 12:48:04 +08:00
6b06184d03
3379. [Usaco2004 Open]Turning in Homework 交作业
https://hydro.ac/d/bzoj/record/6322ae00bdf9bc31d1606239
2022-09-15 12:46:17 +08:00
320af422bd
1799. [Ahoi2009] self 同类分布
https://hydro.ac/d/bzoj/record/6322adbfbdf9bc31d16061fa
2022-09-15 12:44:52 +08:00
58b85e4ba4
3928. [CERC2014] Outer space invaders
https://hydro.ac/d/bzoj/record/6322ac7bbdf9bc31d1606151
2022-09-15 12:39:28 +08:00
60bd85ed1b
3522. [POI2014]Hotel
https://hydro.ac/d/bzoj/record/6322aadfbdf9bc31d1605fa0
2022-09-15 12:33:33 +08:00
3f348509df
4758. [USACO2017 Jan] Subsequence Reversal
https://hydro.ac/d/bzoj/record/6322a3d7bdf9bc31d1605b7c
2022-09-15 12:03:31 +08:00
0c3e00a97b
4380. [POI2015]Myjnie
https://hydro.ac/d/bzoj/record/6322a2ebbdf9bc31d1605b23
2022-09-15 12:01:41 +08:00
226513485c
P4269 [USACO18FEB]Snow Boots G
https://www.luogu.com.cn/record/86653460
2022-09-15 11:39:16 +08:00
482 changed files with 2675 additions and 0 deletions

81
BZOJ/1098/1098.cpp Normal file
View File

@ -0,0 +1,81 @@
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <vector>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 1e5 + 5;
int n, m, cnt, ans[N];
std::vector<int> g[N];
std::set<int> set;
bool vis[N];
void bfs(int x) {
std::queue<int> q;
set.erase(x);
q.push(x);
ans[cnt]++;
while (!q.empty()) {
int u = q.front();
q.pop();
vis[u] = true;
for (auto it = set.begin(); it != set.end();) {
int v = *it;
if (*std::lower_bound(g[u].begin(), g[u].end(), v) != v) {
q.push(v);
ans[cnt]++;
set.erase(it++);
} else {
it++;
}
}
}
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> m;
for (int i = 1, u, v; i <= m; i++) {
cin >> u >> v;
g[u].push_back(v);
g[v].push_back(u);
}
std::for_each(g + 1, g + n + 1, [&](auto& v) { std::sort(v.begin(), v.end()); });
for (int i = 1; i <= n; i++) {
set.insert(i);
}
for (int i = 1; i <= n; i++) {
if (!vis[i]) {
cnt++;
bfs(i);
}
}
std::sort(ans + 1, ans + 1 + cnt);
cout << cnt << endl;
for (int i = 1; i <= cnt; i++) {
cout << ans[i] << ' ';
}
cout << endl;
return 0;
}

BIN
BZOJ/1098/data/1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1098/data/1.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1098/data/10.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1098/data/10.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1098/data/11.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1098/data/11.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1098/data/12.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1098/data/12.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1098/data/13.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1098/data/13.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1098/data/14.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1098/data/14.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1098/data/15.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1098/data/15.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1098/data/2.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1098/data/2.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1098/data/3.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1098/data/3.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1098/data/4.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1098/data/4.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1098/data/5.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1098/data/5.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1098/data/6.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1098/data/6.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1098/data/7.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1098/data/7.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1098/data/8.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1098/data/8.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1098/data/9.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1098/data/9.out (Stored with Git LFS) Normal file

Binary file not shown.

126
BZOJ/1391/1391.cpp Normal file
View File

@ -0,0 +1,126 @@
#pragma GCC optimize("Ofast")
#include <iostream>
#include <cstring>
#include <limits>
#include <queue>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 2e6 + 5;
int n, m, s, t, sum;
int idx, head[N], edge[N << 1], ver[N << 1], next[N << 1];
int dist[N], cur[N];
void add(int u, int v, int w) {
next[idx] = head[u];
ver[idx] = v;
edge[idx] = w;
head[u] = idx++;
}
bool bfs() {
memset(dist, 0x00, sizeof(dist));
std::queue<int> q;
dist[s] = 1;
q.push(s);
cur[s] = head[s];
while (!q.empty()) {
int u = q.front();
q.pop();
for (int i = head[u]; ~i; i = next[i]) {
int v = ver[i],
w = edge[i];
if (w && !dist[v]) {
dist[v] = dist[u] + 1;
cur[v] = head[v];
if (v == t) return true;
q.push(v);
}
}
}
return false;
}
int dinic(int u, int limit) {
if (u == t) return limit;
int flow = 0;
for (int i = cur[u]; ~i && flow < limit; i = next[i]) {
cur[u] = i;
int v = ver[i],
w = edge[i];
if (w && dist[v] == dist[u] + 1) {
int k = dinic(v, std::min(limit - flow, w));
if (!k) dist[v] = 0;
edge[i] -= k;
edge[i ^ 1] += k;
flow += k;
}
}
return flow;
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
memset(head, 0xff, sizeof(head));
cin >> n >> m;
s = 0, t = n + m + 1;
for (int i = 1; i <= n; i++) {
int x, t;
cin >> x >> t;
add(s, i, x);
add(i, s, 0);
sum += x;
for (int j = 1; j <= t; j++) {
int a, b;
cin >> a >> b;
add(i, a + n, b);
add(a + n, i, 0);
}
}
for (int i = 1; i <= m; i++) {
int y;
cin >> y;
add(i + n, t, y);
add(t, i + n, 0);
}
int res = 0, flow;
while (bfs()) {
while (flow = dinic(s, std::numeric_limits<int>::max())) res += flow;
}
cout << sum - res << endl;
return 0;
}

BIN
BZOJ/1391/data/1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1391/data/1.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1391/data/10.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1391/data/10.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1391/data/11.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1391/data/11.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1391/data/12.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1391/data/12.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1391/data/13.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1391/data/13.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1391/data/14.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1391/data/14.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1391/data/15.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1391/data/15.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1391/data/16.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1391/data/16.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1391/data/17.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1391/data/17.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1391/data/18.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1391/data/18.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1391/data/2.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1391/data/2.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1391/data/3.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1391/data/3.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1391/data/4.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1391/data/4.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1391/data/5.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1391/data/5.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1391/data/6.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1391/data/6.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1391/data/7.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1391/data/7.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1391/data/8.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1391/data/8.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1391/data/9.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1391/data/9.out (Stored with Git LFS) Normal file

Binary file not shown.

55
BZOJ/1799/1799.cpp Normal file
View File

@ -0,0 +1,55 @@
#include <iostream>
#include <bitset>
#include <cstring>
using std::cin;
using std::cout;
const char endl = '\n';
long long a, b, f[20][200][200], ans;
int c[20], p;
long long dfs(int len, int s, int x, bool limit) {
if (s + 9 * len < p) return 0;
if (!limit && f[len][s][x] != -1) return f[len][s][x];
if (!len) return s == p && x == 0;
int n = limit ? c[len] : 9;
long long res = 0;
for (int i = 0; i <= n && i + s <= p; i++)
res += dfs(len - 1, s + i, (x * 10 + i) % p, limit && (i == c[len]));
if (!limit) f[len][s][x] = res;
return res;
}
long long calc(long long x) {
int cnt = 0;
while (x) {
c[++cnt] = x % 10;
x /= 10;
}
long long res = 0;
for (p = 1; p <= cnt * 9; p++) {
memset(f, 0xff, sizeof(f));
res += dfs(cnt, 0, 0, 1);
}
return res;
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> a >> b;
cout << calc(b) - calc(a - 1) << endl;
return 0;
}

BIN
BZOJ/1799/data/1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1799/data/1.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1799/data/10.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1799/data/10.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1799/data/2.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1799/data/2.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1799/data/3.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1799/data/3.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1799/data/4.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1799/data/4.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1799/data/5.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1799/data/5.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1799/data/6.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1799/data/6.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1799/data/7.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1799/data/7.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1799/data/8.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1799/data/8.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1799/data/9.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1799/data/9.out (Stored with Git LFS) Normal file

Binary file not shown.

81
BZOJ/1827/1827.cpp Normal file
View File

@ -0,0 +1,81 @@
#include <iostream>
#include <vector>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 1e5 + 5;
int n, sum, root, c[N], siz[N], max_siz[N], dep[N];
long long ans;
std::vector<std::pair<int, int>> g[N];
void dfs1(int u, int f) {
siz[u] = c[u];
for (auto e : g[u]) {
int v = e.first,
w = e.second;
if (v == f) continue;
dfs1(v, u);
siz[u] += siz[v];
max_siz[u] = std::max(max_siz[u], siz[v]);
}
max_siz[u] = std::max(max_siz[u], sum - siz[u]);
}
void dfs2(int u, int f) {
for (auto e : g[u]) {
int v = e.first,
w = e.second;
if (v == f) continue;
dep[v] = dep[u] + w;
dfs2(v, u);
}
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> c[i];
sum += c[i];
}
for (int i = 1, u, v, w; i <= n; i++) {
cin >> u >> v >> w;
g[u].emplace_back(v, w);
g[v].emplace_back(u, w);
}
dfs1(1, 0);
for (int i = 1; i <= n; i++) {
if (!root || max_siz[i] < max_siz[root]) {
root = i;
}
}
dep[0] = -1;
dfs2(root, 0);
for (int i = 1; i <= n; i++) {
ans += static_cast<long long>(c[i]) * dep[i];
}
cout << ans << endl;
return 0;
}

BIN
BZOJ/1827/data/1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1827/data/1.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1827/data/10.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1827/data/10.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1827/data/2.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1827/data/2.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1827/data/3.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1827/data/3.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1827/data/4.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/1827/data/4.out (Stored with Git LFS) Normal file

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More