Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define fi first
- #define se second
- #define pb push_back
- #define all(x) x.begin(),x.end()
- #define rall(x) x.rbegin(),x.rend()
- using namespace std;
- using ii = pair<int, int>;
- using i64 = long long;
- const int INF = 0x3f3f3f3f;
- const i64 INFLL = 0x3f3f3f3f3f3f3f3f;
- int main() {
- cin.tie(0)->sync_with_stdio(0);
- int l, s; cin >> l >> s;
- if (l == s and l == 1) {
- cout << "2 1\n1 2\n";
- return 0;
- }
- if (2*s < l or s > l) {
- cout << "-1\n";
- return 0;
- }
- if (s + 1 == l) {
- if (l == 2) {
- cout << "4 4\n";
- cout << "1 2\n";
- cout << "2 3\n";
- cout << "2 4\n";
- cout << "3 4\n";
- return 0;
- }
- int qtdCycle = 2 * l - 2;
- cout << 1 + qtdCycle << ' ' << 1 + qtdCycle << '\n';
- for (int u = 1; u <= qtdCycle; ++u) {
- if (u == qtdCycle) {
- cout << qtdCycle << ' ' << "1\n";
- continue;
- }
- cout << u << ' ' << u+1 << '\n';
- }
- cout << qtdCycle+1 << ' ' << "1\n";
- return 0;
- }
- if (s == (l+1)/2) {
- cout << l+1 << ' ' << l << '\n';
- for (int i = 0; i < l; ++i) {
- cout << i+1 << ' ' << i+2 << '\n';
- }
- } else if (s == l) {
- int qtdCycle = 2 * l;
- cout << qtdCycle << ' ' << qtdCycle << '\n';
- for (int u = 1; u <= qtdCycle; ++u) {
- if (u == qtdCycle) {
- cout << qtdCycle << ' ' << "1\n";
- continue;
- }
- cout << u << ' ' << u+1 << '\n';
- }
- } else {
- int qtdNodes = 2 * s + 2 * (l - s) - 1;
- vector<ii> edges;
- for (int u = 1; u <= 2 * s; ++u) {
- if (u == 2*s) {
- edges.push_back({u, 1});
- } else {
- edges.push_back({u, u+1});
- }
- }
- int delta = 2 * s;
- if (s != l) {
- edges.push_back({1, delta+1});
- }
- for (int u = 1; u < 2*(l-s); ++u) {
- if (u == 2*(l-s)-1) {
- // cout << delta+u << ' ' << "1\n";
- edges.push_back({delta+u, 1});
- } else {
- // cout << delta+u << ' ' << delta+u+1 << '\n';
- edges.push_back({delta+u, delta+u+1});
- }
- }
- cout << qtdNodes << ' ' << edges.size() << '\n';
- for (auto [a, b] : edges) {
- cout << a << ' ' << b << '\n';
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment