Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define all(x) x.begin(), x.end()
- #define rall(x) x.rbegin(), x.rend()
- #define F first
- #define S second
- #define pb push_back
- #define ll long long
- //#define PROBLEM "solid"
- using namespace std;
- const int MAXN = 1000;
- const int INF = 1e7;
- int main() {
- #ifndef LOCAL
- #ifdef PROBLEM
- freopen(PROBLEM".in", "r", stdin);
- freopen(PROBLEM".out", "w", stdout);
- #endif
- #endif
- #ifdef LOCAL
- //freopen("/Users/alekseygolub/Desktop/ะก++/ABS/ABS/input.txt", "r", stdin);
- #endif
- cin.tie(0);
- cout.tie(0);
- ios_base::sync_with_stdio(0);
- //---------------------------------------------------------------------------------------------------------
- int n, m;
- cin >> n >> m;
- if (n != m && m != ((n*(n - 1)) / 2)) {
- cout << "Impossible";
- return 0;
- }
- set<pair<int, int>> ans;
- cout << "Possible" << '\n';
- if (n == m) {
- for (int i = 1; i < n; i++) {
- int j = i + 1;
- ans.insert({min(i, j), max(i, j)});
- }
- ans.insert({1, n});
- } else {
- for (int i = 1; i <= n; i++) {
- for (int j = 1; j <= n; j++) {
- if (i != j)
- ans.insert({min(i, j), max(i, j)});
- }
- }
- }
- for (auto x: ans) {
- if (x.F == x.S) throw new exception;
- cout << x.F << " " << x.S << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement