This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int INF = (int) 1e9 + 1e6 + 123;
const ll LINF = (ll) 1e18 + 1e9 + 123;
#define rep(i, s, t) for (auto i = (s); i < (t); ++(i))
#define per(i, s, t) for (auto i = (s); i >= (t); --(i))
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
bool mini(auto &x, const auto &y) {
if (y < x) {
x = y;
return 1;
}
return 0;
}
bool maxi(auto &x, const auto &y) {
if (y > x) {
x = y;
return 1;
}
return 0;
}
void run();
mt19937 rnd;
int main(int argc, char *argv[]) {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
rnd.seed(atoi(argv[1]));
run();
return 0;
}
const int T = 100;
const int N = 10;
const int M = 15;
const int P = 5;
struct E {
int a, b;
};
int n, m;
E e[T];
bool can[T][T];
bool can_left[T], can_right[T];
int p;
int x[T], y[T];
void floyd() {
rep(k, 1, n + 1) rep(i, 1, n + 1) rep(j, 1, n + 1) can[i][j] |= can[i][k] && can[k][j];
}
bool test(int mask, int bit) {
return mask & (1 << bit);
}
void run() {
bool test_ok = 0;
do {
n = rnd() % N + 2;
m = rnd() % M;
p = rnd() % P;
rep(i, 0, m) {
int u, v;
do {
u = rnd() % n + 1;
v = rnd() % n + 1;
} while (u == v);
e[i] = {u, v};
}
rep(i, 0, p) {
int u, v;
do {
u = rnd() % n + 1;
v = rnd() % n + 1;
} while (u == v);
x[i] = u;
y[i] = v;
}
test_ok = 0;
rep(mask, 0, 1 << m) {
memset(can, 0, sizeof can);
rep(i, 0, m) {
int u = e[i].a;
int v = e[i].b;
if (test(mask, i)) {
swap(u, v);
}
can[u][v] |= 1;
}
floyd();
bool ok = 1;
rep(i, 0, p) {
ok &= can[x[i]][y[i]];
}
if (!ok) continue;
test_ok = 1;
break;
}
} while (!test_ok);
cout << n << " " << m << "\n";
rep(i, 0, m) {
cout << e[i].a << " " << e[i].b << "\n";
}
cout << p << "\n";
rep(i, 0, p) {
cout << x[i] << " " << y[i] << "\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |