0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-03 19:16:27 +00:00

Compare commits

..

No commits in common. "d22fe79fff91a9082d50cb17caa7c747a1955594" and "6967e637f1039d5686c1d279377bc883c7cdf76a" have entirely different histories.

261 changed files with 70 additions and 1698 deletions

View File

@ -1,18 +0,0 @@
#include <iostream>
using std::cin;
using std::cout;
const char endl = '\n';
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
int a, b;
cin >> a >> b;
cout << (b - a == 1 && a != 3 && a != 6 && a != 9 && b != 1 && b != 4 && b != 7 ? "Yes" : "No") << endl;
return 0;
}

View File

@ -1,56 +0,0 @@
#include <iostream>
#include <string>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 105;
int n;
std::string a[N], b[N];
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
b[i] = a[i] = ' ' + a[i];
}
for (int i = 2; i <= n; i++) {
b[1][i] = a[1][i - 1];
}
for (int i = 1; i < n; i++) {
b[i][1] = a[i + 1][1];
}
for (int i = 1; i < n; i++) {
b[n][i] = a[n][i + 1];
}
for (int i = 2; i <= n; i++) {
b[i][n] = a[i - 1][n];
}
for (int i = 2; i < n; i++) {
for (int j = 2; j < n; j++) {
b[i][j] = a[i][j];
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
cout << b[i][j];
}
cout << endl;
}
return 0;
}

View File

@ -1,141 +0,0 @@
#include <iostream>
#include <functional>
#include <memory>
#include <stack>
#include <vector>
using std::cin;
using std::cout;
const char endl = '\n';
template <typename T, class Compare = std::less<T>>
class LeftistTree : public std::enable_shared_from_this<LeftistTree<T, Compare>> {
public:
using pointer_type = std::shared_ptr<LeftistTree<T, Compare>>;
protected:
static Compare comp;
private:
size_t dist;
pointer_type lchild, rchild;
std::weak_ptr<LeftistTree<T, Compare>> root;
public:
T id, val;
LeftistTree(const T& _val = 0, const T& _id = 0)
: dist(0),
lchild(nullptr),
rchild(nullptr),
root(),
id(_id),
val(_val) {}
pointer_type find_root() {
std::stack<pointer_type> st;
pointer_type cur = this->shared_from_this();
st.emplace(cur);
while (auto ptr = cur->root.lock()) {
st.emplace(cur = ptr);
}
while (!st.empty()) {
auto ptr = st.top();
st.pop();
ptr->root = cur;
}
cur->root.reset();
return cur;
}
void erase() {
if (lchild) lchild->root.reset();
if (rchild) rchild->root.reset();
root = merge(lchild, rchild);
}
static pointer_type merge(pointer_type x, pointer_type y) {
if (!x) return y;
if (!y) return x;
if (comp(x->val, y->val) || x->val == y->val && comp(x->id, y->id)) std::swap(x, y);
x->rchild = merge(x->rchild, y);
if (!x->lchild || x->lchild->dist < x->rchild->dist) std::swap(x->lchild, x->rchild);
if (x->lchild) x->lchild->root = x;
if (x->rchild) x->rchild->root = x;
x->dist = x->rchild ? x->rchild->dist + 1 : 0;
return x;
}
};
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, m;
cin >> n >> m;
std::vector<bool> exists(n + 1, true);
std::vector<LeftistTree<int, std::greater<>>::pointer_type> tr(n + 1);
for (int i = 1, x; i <= n; i++) {
cin >> x;
tr[i] = std::make_shared<decltype(tr)::value_type::element_type>(x, i);
}
while (m--) {
int op;
cin >> op;
if (op == 1) {
int x, y;
cin >> x >> y;
if (exists[x] && exists[y]) {
auto fx = tr[x]->find_root(),
fy = tr[y]->find_root();
if (fx != fy) {
decltype(tr)::value_type::element_type::merge(fx, fy);
}
}
} else { // op == 2
int x;
cin >> x;
if (exists[x]) {
auto fx = tr[x]->find_root();
if (exists[fx->id]) {
cout << fx->val << endl;
fx->erase();
exists[fx->id] = false;
} else {
cout << -1 << endl;
}
} else {
cout << -1 << endl;
}
}
}
return 0;
}

BIN
LibreOJ/188/data/1.in (Stored with Git LFS)

Binary file not shown.

BIN
LibreOJ/188/data/1.out (Stored with Git LFS)

Binary file not shown.

BIN
LibreOJ/188/data/10.in (Stored with Git LFS)

Binary file not shown.

BIN
LibreOJ/188/data/10.out (Stored with Git LFS)

Binary file not shown.

BIN
LibreOJ/188/data/11.in (Stored with Git LFS)

Binary file not shown.

BIN
LibreOJ/188/data/11.out (Stored with Git LFS)

Binary file not shown.

BIN
LibreOJ/188/data/12.in (Stored with Git LFS)

Binary file not shown.

BIN
LibreOJ/188/data/12.out (Stored with Git LFS)

Binary file not shown.

BIN
LibreOJ/188/data/13.in (Stored with Git LFS)

Binary file not shown.

BIN
LibreOJ/188/data/13.out (Stored with Git LFS)

Binary file not shown.

BIN
LibreOJ/188/data/14.in (Stored with Git LFS)

Binary file not shown.

BIN
LibreOJ/188/data/14.out (Stored with Git LFS)

Binary file not shown.

BIN
LibreOJ/188/data/15.in (Stored with Git LFS)

Binary file not shown.

BIN
LibreOJ/188/data/15.out (Stored with Git LFS)

Binary file not shown.

BIN
LibreOJ/188/data/16.in (Stored with Git LFS)

Binary file not shown.

BIN
LibreOJ/188/data/16.out (Stored with Git LFS)

Binary file not shown.

BIN
LibreOJ/188/data/17.in (Stored with Git LFS)

Binary file not shown.

BIN
LibreOJ/188/data/17.out (Stored with Git LFS)

Binary file not shown.

BIN
LibreOJ/188/data/18.in (Stored with Git LFS)

Binary file not shown.

BIN
LibreOJ/188/data/18.out (Stored with Git LFS)

Binary file not shown.

BIN
LibreOJ/188/data/19.in (Stored with Git LFS)

Binary file not shown.

BIN
LibreOJ/188/data/19.out (Stored with Git LFS)

Binary file not shown.

BIN
LibreOJ/188/data/2.in (Stored with Git LFS)

Binary file not shown.

BIN
LibreOJ/188/data/2.out (Stored with Git LFS)

Binary file not shown.

BIN
LibreOJ/188/data/20.in (Stored with Git LFS)

Binary file not shown.

BIN
LibreOJ/188/data/20.out (Stored with Git LFS)

Binary file not shown.

BIN
LibreOJ/188/data/3.in (Stored with Git LFS)

Binary file not shown.

BIN
LibreOJ/188/data/3.out (Stored with Git LFS)

Binary file not shown.

BIN
LibreOJ/188/data/4.in (Stored with Git LFS)

Binary file not shown.

BIN
LibreOJ/188/data/4.out (Stored with Git LFS)

Binary file not shown.

BIN
LibreOJ/188/data/5.in (Stored with Git LFS)

Binary file not shown.

BIN
LibreOJ/188/data/5.out (Stored with Git LFS)

Binary file not shown.

BIN
LibreOJ/188/data/6.in (Stored with Git LFS)

Binary file not shown.

BIN
LibreOJ/188/data/6.out (Stored with Git LFS)

Binary file not shown.

BIN
LibreOJ/188/data/7.in (Stored with Git LFS)

Binary file not shown.

BIN
LibreOJ/188/data/7.out (Stored with Git LFS)

Binary file not shown.

BIN
LibreOJ/188/data/8.in (Stored with Git LFS)

Binary file not shown.

BIN
LibreOJ/188/data/8.out (Stored with Git LFS)

Binary file not shown.

BIN
LibreOJ/188/data/9.in (Stored with Git LFS)

Binary file not shown.

BIN
LibreOJ/188/data/9.out (Stored with Git LFS)

Binary file not shown.

BIN
LibreOJ/188/data/problem.conf (Stored with Git LFS)

Binary file not shown.

BIN
LibreOJ/188/data/std.cpp (Stored with Git LFS)

Binary file not shown.

BIN
LibreOJ/188/data/val.cpp (Stored with Git LFS)

Binary file not shown.

View File

@ -1,68 +0,0 @@
/**
* @file S2OJ/1974/gen.cpp
* @author Baoshuo <i@baoshuo.ren>
* @url https://baoshuo.ren
*/
#include "testlib.h"
#include <iostream>
#include <limits>
using std::cin;
using std::cout;
const char endl = '\n';
#define N_TESTS 20
#define PERCENT_TESTS(_percent) (static_cast<double>(_percent) / 100 * N_TESTS)
int main(int argc, char* argv[]) {
registerGen(argc, argv, 1);
int id = opt<int>("id");
int min_n = 100000,
max_n = 100000; // 1e5
int min_m = 100000,
max_m = 100000; // 1e5
std::cerr << PERCENT_TESTS(30) << endl;
if (id <= PERCENT_TESTS(30)) {
min_n = max_n = 10;
min_m = max_m = 10;
} else if (id <= PERCENT_TESTS(70)) {
min_n = max_n = 1000;
min_m = max_m = 1000;
} else { // all tests
// (none)
}
int n = rnd.next(min_n, max_n);
int m = rnd.next(min_m, max_m);
cout << n << ' ' << m << endl;
for (int i = 1; i <= n; i++) {
const char end_c = i < n ? ' ' : '\n';
cout << rnd.next(std::numeric_limits<int>::min(), std::numeric_limits<int>::max()) << end_c;
}
for (int i = 1; i <= m; i++) {
int op = rnd.next(1, 2);
if (op == 1) {
int x = rnd.next(1, n);
int y = rnd.next(1, n);
cout << op << ' ' << x << ' ' << y << endl;
} else {
int x = rnd.next(1, n);
cout << op << ' ' << x << endl;
}
}
return 0;
}

View File

@ -1,39 +1,28 @@
#include <iostream>
#include <string>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 1e6 + 5;
int next[N];
std::string s1, s2;
int nxt[1000005];
std::string s, p;
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> s1 >> s2;
next[0] = -1;
for (int i = 1, j = -1; i < s2.size(); i++) {
while (~j && s2[j + 1] != s2[i]) j = next[j];
if (s2[j + 1] == s2[i]) j++;
next[i] = j;
cin >> s >> p;
nxt[0] = -1;
for (int i = 1, j = -1; i < p.size(); i++) {
while (j >= 0 && p[j + 1] != p[i]) j = nxt[j];
if (p[j + 1] == p[i]) j++;
nxt[i] = j;
}
for (int i = 0, j = -1; i < s1.size(); i++) {
while (~j && s1[i] != s2[j + 1]) j = next[j];
if (s1[i] == s2[j + 1]) j++;
if (j + 1 == s2.size()) {
for (int i = 0, j = -1; i < s.size(); i++) {
while (j != -1 && s[i] != p[j + 1]) j = nxt[j];
if (s[i] == p[j + 1]) j++;
if (j == p.size() - 1) {
cout << i - j + 1 << endl;
j = nxt[j];
}
}
return 0;
}

View File

@ -1,63 +1,76 @@
#include <iostream>
#pragma GCC optimize("Ofast")
using std::cin;
using std::cout;
const char endl = '\n';
#include <bits/stdc++.h>
const int N = 1e6 + 5;
using namespace std;
int q, p, primes[N], sig[N], miu[N], phi[N];
bool is_prime[N];
int q, p, op, k, prime[1000005], miu[1000005], phi[1000005];
long long sig[1000005];
bool is_prime[1000005];
template <typename T>
inline void read(T& x) {
x = 0;
int f = 1;
char ch;
while (!isdigit(ch = getchar())) {
if (ch == '-') f = -1;
}
while (isdigit(ch)) {
x = x * 10 + (ch ^ 48);
ch = getchar();
}
x *= f;
}
template <typename T>
void write(T x) {
if (x < 0) {
putchar('-');
x = -x;
}
if (x > 9) {
write(x / 10);
}
putchar(x % 10 + '0');
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
// ======
phi[1] = miu[1] = sig[1] = 1;
for (int i = 2; i < N; i++) {
for (int i = 2; i <= 1000000; i++) {
if (!is_prime[i]) {
primes[++p] = i;
prime[++p] = i;
phi[i] = i - 1;
miu[i] = -1;
sig[i] = i + 1;
}
for (int j = 1; j <= p && primes[j] * i < N; j++) {
is_prime[i * primes[j]] = 1;
miu[i * primes[j]] = -miu[i];
phi[i * primes[j]] = phi[i] * phi[primes[j]];
sig[i * primes[j]] = sig[i] * sig[primes[j]];
if (i % primes[j] == 0) {
miu[i * primes[j]] = 0;
phi[i * primes[j]] = phi[i] * primes[j];
sig[i * primes[j]] -= sig[i / primes[j]] * primes[j];
for (int j = 1; j <= p && prime[j] * i <= 1000000; j++) {
is_prime[i * prime[j]] = 1, miu[i * prime[j]] = -miu[i];
phi[i * prime[j]] = phi[i] * phi[prime[j]];
sig[i * prime[j]] = sig[i] * sig[prime[j]];
if (i % prime[j] == 0) {
miu[i * prime[j]] = 0;
phi[i * prime[j]] = phi[i] * prime[j];
sig[i * prime[j]] -= sig[i / prime[j]] * prime[j];
break;
}
}
}
// ======
cin >> q;
while (q--) {
int op, k;
cin >> op >> k;
read(q);
for (int i = 0; i < q; i++) {
read(op);
read(k);
if (op == 1) {
cout << primes[k] << endl;
} else { // op == 2
cout << sig[k] << ' ' << miu[k] << ' ' << phi[k] << endl;
write(prime[k]);
putchar('\n');
} else {
write(sig[k]);
putchar(' ');
write(miu[k]);
putchar(' ');
write(phi[k]);
putchar('\n');
}
}
return 0;
}

View File

@ -1,141 +0,0 @@
#include <iostream>
#include <functional>
#include <memory>
#include <stack>
#include <vector>
using std::cin;
using std::cout;
const char endl = '\n';
template <typename T, class Compare = std::less<T>>
class LeftistTree : public std::enable_shared_from_this<LeftistTree<T, Compare>> {
public:
using pointer_type = std::shared_ptr<LeftistTree<T, Compare>>;
protected:
static Compare comp;
private:
size_t dist;
pointer_type lchild, rchild;
std::weak_ptr<LeftistTree<T, Compare>> root;
public:
T id, val;
LeftistTree(const T& _val = 0, const T& _id = 0)
: dist(0),
lchild(nullptr),
rchild(nullptr),
root(),
id(_id),
val(_val) {}
pointer_type find_root() {
std::stack<pointer_type> st;
pointer_type cur = this->shared_from_this();
st.emplace(cur);
while (auto ptr = cur->root.lock()) {
st.emplace(cur = ptr);
}
while (!st.empty()) {
auto ptr = st.top();
st.pop();
ptr->root = cur;
}
cur->root.reset();
return cur;
}
void erase() {
if (lchild) lchild->root.reset();
if (rchild) rchild->root.reset();
root = merge(lchild, rchild);
}
static pointer_type merge(pointer_type x, pointer_type y) {
if (!x) return y;
if (!y) return x;
if (comp(x->val, y->val) || x->val == y->val && comp(x->id, y->id)) std::swap(x, y);
x->rchild = merge(x->rchild, y);
if (!x->lchild || x->lchild->dist < x->rchild->dist) std::swap(x->lchild, x->rchild);
if (x->lchild) x->lchild->root = x;
if (x->rchild) x->rchild->root = x;
x->dist = x->rchild ? x->rchild->dist + 1 : 0;
return x;
}
};
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, m;
cin >> n >> m;
std::vector<bool> exists(n + 1, true);
std::vector<LeftistTree<int, std::greater<>>::pointer_type> tr(n + 1);
for (int i = 1, x; i <= n; i++) {
cin >> x;
tr[i] = std::make_shared<decltype(tr)::value_type::element_type>(x, i);
}
while (m--) {
int op;
cin >> op;
if (op == 1) {
int x, y;
cin >> x >> y;
if (exists[x] && exists[y]) {
auto fx = tr[x]->find_root(),
fy = tr[y]->find_root();
if (fx != fy) {
decltype(tr)::value_type::element_type::merge(fx, fy);
}
}
} else { // op == 2
int x;
cin >> x;
if (exists[x]) {
auto fx = tr[x]->find_root();
if (exists[fx->id]) {
cout << fx->val << endl;
fx->erase();
exists[fx->id] = false;
} else {
cout << -1 << endl;
}
} else {
cout << -1 << endl;
}
}
}
return 0;
}

BIN
S2OJ/1974/data/1.in (Stored with Git LFS)

Binary file not shown.

BIN
S2OJ/1974/data/1.out (Stored with Git LFS)

Binary file not shown.

BIN
S2OJ/1974/data/10.in (Stored with Git LFS)

Binary file not shown.

BIN
S2OJ/1974/data/10.out (Stored with Git LFS)

Binary file not shown.

BIN
S2OJ/1974/data/11.in (Stored with Git LFS)

Binary file not shown.

BIN
S2OJ/1974/data/11.out (Stored with Git LFS)

Binary file not shown.

BIN
S2OJ/1974/data/12.in (Stored with Git LFS)

Binary file not shown.

BIN
S2OJ/1974/data/12.out (Stored with Git LFS)

Binary file not shown.

BIN
S2OJ/1974/data/13.in (Stored with Git LFS)

Binary file not shown.

BIN
S2OJ/1974/data/13.out (Stored with Git LFS)

Binary file not shown.

BIN
S2OJ/1974/data/14.in (Stored with Git LFS)

Binary file not shown.

BIN
S2OJ/1974/data/14.out (Stored with Git LFS)

Binary file not shown.

BIN
S2OJ/1974/data/15.in (Stored with Git LFS)

Binary file not shown.

BIN
S2OJ/1974/data/15.out (Stored with Git LFS)

Binary file not shown.

BIN
S2OJ/1974/data/16.in (Stored with Git LFS)

Binary file not shown.

BIN
S2OJ/1974/data/16.out (Stored with Git LFS)

Binary file not shown.

BIN
S2OJ/1974/data/17.in (Stored with Git LFS)

Binary file not shown.

BIN
S2OJ/1974/data/17.out (Stored with Git LFS)

Binary file not shown.

BIN
S2OJ/1974/data/18.in (Stored with Git LFS)

Binary file not shown.

BIN
S2OJ/1974/data/18.out (Stored with Git LFS)

Binary file not shown.

BIN
S2OJ/1974/data/19.in (Stored with Git LFS)

Binary file not shown.

BIN
S2OJ/1974/data/19.out (Stored with Git LFS)

Binary file not shown.

BIN
S2OJ/1974/data/2.in (Stored with Git LFS)

Binary file not shown.

BIN
S2OJ/1974/data/2.out (Stored with Git LFS)

Binary file not shown.

BIN
S2OJ/1974/data/20.in (Stored with Git LFS)

Binary file not shown.

BIN
S2OJ/1974/data/20.out (Stored with Git LFS)

Binary file not shown.

BIN
S2OJ/1974/data/3.in (Stored with Git LFS)

Binary file not shown.

BIN
S2OJ/1974/data/3.out (Stored with Git LFS)

Binary file not shown.

BIN
S2OJ/1974/data/4.in (Stored with Git LFS)

Binary file not shown.

BIN
S2OJ/1974/data/4.out (Stored with Git LFS)

Binary file not shown.

BIN
S2OJ/1974/data/5.in (Stored with Git LFS)

Binary file not shown.

BIN
S2OJ/1974/data/5.out (Stored with Git LFS)

Binary file not shown.

BIN
S2OJ/1974/data/6.in (Stored with Git LFS)

Binary file not shown.

BIN
S2OJ/1974/data/6.out (Stored with Git LFS)

Binary file not shown.

BIN
S2OJ/1974/data/7.in (Stored with Git LFS)

Binary file not shown.

BIN
S2OJ/1974/data/7.out (Stored with Git LFS)

Binary file not shown.

BIN
S2OJ/1974/data/8.in (Stored with Git LFS)

Binary file not shown.

BIN
S2OJ/1974/data/8.out (Stored with Git LFS)

Binary file not shown.

BIN
S2OJ/1974/data/9.in (Stored with Git LFS)

Binary file not shown.

BIN
S2OJ/1974/data/9.out (Stored with Git LFS)

Binary file not shown.

BIN
S2OJ/1974/data/problem.conf (Stored with Git LFS)

Binary file not shown.

BIN
S2OJ/1974/data/std.cpp (Stored with Git LFS)

Binary file not shown.

BIN
S2OJ/1974/data/val.cpp (Stored with Git LFS)

Binary file not shown.

View File

@ -1,68 +0,0 @@
/**
* @file S2OJ/1974/gen.cpp
* @author Baoshuo <i@baoshuo.ren>
* @url https://baoshuo.ren
*/
#include "testlib.h"
#include <iostream>
#include <limits>
using std::cin;
using std::cout;
const char endl = '\n';
#define N_TESTS 20
#define PERCENT_TESTS(_percent) (static_cast<double>(_percent) / 100 * N_TESTS)
int main(int argc, char* argv[]) {
registerGen(argc, argv, 1);
int id = opt<int>("id");
int min_n = 100000,
max_n = 100000; // 1e5
int min_m = 100000,
max_m = 100000; // 1e5
std::cerr << PERCENT_TESTS(30) << endl;
if (id <= PERCENT_TESTS(30)) {
min_n = max_n = 10;
min_m = max_m = 10;
} else if (id <= PERCENT_TESTS(70)) {
min_n = max_n = 1000;
min_m = max_m = 1000;
} else { // all tests
// (none)
}
int n = rnd.next(min_n, max_n);
int m = rnd.next(min_m, max_m);
cout << n << ' ' << m << endl;
for (int i = 1; i <= n; i++) {
const char end_c = i < n ? ' ' : '\n';
cout << rnd.next(std::numeric_limits<int>::min(), std::numeric_limits<int>::max()) << end_c;
}
for (int i = 1; i <= m; i++) {
int op = rnd.next(1, 2);
if (op == 1) {
int x = rnd.next(1, n);
int y = rnd.next(1, n);
cout << op << ' ' << x << ' ' << y << endl;
} else {
int x = rnd.next(1, n);
cout << op << ' ' << x << endl;
}
}
return 0;
}

View File

@ -1,114 +0,0 @@
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 1e4 + 5;
const int INF = 0x3f3f3f3f;
int n, m, a[N];
std::vector<int> g[N], g2[N];
int cnt, dfn[N], low[N];
int scc_cnt, id[N], w[N], dist[N];
bool vis[N];
std::stack<int> st;
void tarjan(int u) {
dfn[u] = low[u] = ++cnt;
vis[u] = true;
st.push(u);
for (int v : g[u]) {
if (!dfn[v]) {
tarjan(v);
low[u] = std::min(low[u], low[v]);
} else if (vis[v]) {
low[u] = std::min(low[u], dfn[v]);
}
}
if (low[u] == dfn[u]) {
scc_cnt++;
int v;
do {
v = st.top();
st.pop();
vis[v] = false;
id[v] = scc_cnt;
w[scc_cnt] += a[v];
} while (v != u);
}
}
int spfa(int s) {
std::fill_n(dist, N, -INF);
int res = 0;
std::queue<int> q;
q.emplace(s);
dist[s] = 0;
while (!q.empty()) {
int u = q.front();
q.pop();
res = std::max(res, dist[u] + w[u]);
for (int v : g2[u]) {
if (dist[v] < dist[u] + w[u]) {
dist[v] = dist[u] + w[u];
q.push(v);
}
}
}
return res;
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> m;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = 1, u, v; i <= m; i++) {
cin >> u >> v;
g[u].emplace_back(v);
}
for (int i = 1; i <= n; i++) {
if (!dfn[i]) {
tarjan(i);
}
}
for (int i = 1; i <= n; i++) {
for (int v : g[i]) {
if (id[i] != id[v]) {
g2[id[i]].emplace_back(id[v]);
}
}
}
int ans = 0;
for (int i = 1; i <= scc_cnt; i++) {
ans = std::max(ans, spfa(i));
}
cout << ans << endl;
return 0;
}

BIN
S2OJ/1991/data/1.in (Stored with Git LFS)

Binary file not shown.

BIN
S2OJ/1991/data/1.out (Stored with Git LFS)

Binary file not shown.

BIN
S2OJ/1991/data/10.in (Stored with Git LFS)

Binary file not shown.

BIN
S2OJ/1991/data/10.out (Stored with Git LFS)

Binary file not shown.

BIN
S2OJ/1991/data/11.in (Stored with Git LFS)

Binary file not shown.

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