0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-10 21:38:47 +00:00

Compare commits

...

3 Commits

70 changed files with 381 additions and 0 deletions

81
Luogu/P3452/P3452.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;
}

51
Luogu/P4824/P4824.cpp Normal file
View File

@ -0,0 +1,51 @@
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stack>
#include <string>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 1e6 + 5;
const int hash = 233333;
int cnt;
char st[N];
std::string s, t;
unsigned long long p = 1, h[N], t_hash;
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> s >> t;
int n = s.size();
int m = t.size();
s = ' ' + s;
for (char c : t) {
t_hash = t_hash * hash + c;
p *= hash;
}
for (int i = 1; i <= n; i++) {
st[++cnt] = s[i];
h[cnt] = h[cnt - 1] * hash + s[i];
if (cnt >= m && h[cnt] - h[cnt - m] * p == t_hash) {
cnt -= m;
}
}
for (int i = 1; i <= cnt; i++) {
cout << st[i];
}
cout << endl;
return 0;
}

48
S2OJ/929/929.cpp Normal file
View File

@ -0,0 +1,48 @@
#include <iostream>
#include <string>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 1e6 + 5;
int t, n;
int cnt, len[N];
int cnt_odd, cnt_even;
std::string s;
long long ans;
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> t >> n >> s;
s = ' ' + s;
len[0] = 1;
for (int i = 1; i <= n; i++) {
len[s[i] == '1' ? ++cnt : cnt]++;
}
for (int i = 1; i <= cnt; i++) {
if (i % 2 == 1) {
ans += static_cast<long long>(cnt_even) * len[i];
cnt_even += len[i - 1];
} else {
ans += static_cast<long long>(cnt_odd) * len[i];
cnt_odd += len[i - 1];
}
}
for (int i = 1; i <= cnt; i++) {
if (len[i - 1] > 1 && len[i] > 1) {
ans += static_cast<long long>(len[i - 1] - 1) * (len[i] - 1);
}
}
cout << ans << endl;
return 0;
}

BIN
S2OJ/929/data/ex_puzzle1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/ex_puzzle1.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/ex_puzzle2.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/ex_puzzle2.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/ex_puzzle3.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/ex_puzzle3.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/problem.conf (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle1.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle10.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle10.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle11.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle11.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle12.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle12.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle13.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle13.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle14.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle14.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle15.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle15.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle16.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle16.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle17.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle17.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle18.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle18.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle19.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle19.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle2.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle2.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle20.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle20.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle21.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle21.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle22.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle22.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle23.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle23.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle24.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle24.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle25.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle25.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle26.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle26.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle27.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle27.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle28.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle28.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle29.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle29.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle3.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle3.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle30.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle30.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle4.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle4.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle5.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle5.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle6.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle6.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle7.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle7.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle8.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle8.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle9.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/929/data/puzzle9.out (Stored with Git LFS) Normal file

Binary file not shown.