Advertisement
Guest User

Untitled

a guest
Oct 21st, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.46 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. #define all(x) x.begin(), x.end()
  4. #define rall(x) x.rbegin(), x.rend()
  5. #define F first
  6. #define S second
  7. #define pb push_back
  8. #define ll long long
  9.  
  10. //#define PROBLEM "solid"
  11.  
  12. using namespace std;
  13.  
  14. const int MAXN = 1000;
  15. const int INF = 1e7;
  16.  
  17. int main() {
  18.     #ifndef LOCAL
  19.         #ifdef PROBLEM
  20.             freopen(PROBLEM".in", "r", stdin);
  21.             freopen(PROBLEM".out", "w", stdout);
  22.         #endif
  23.     #endif
  24.     #ifdef LOCAL
  25.         //freopen("/Users/alekseygolub/Desktop/ะก++/ABS/ABS/input.txt", "r", stdin);
  26.     #endif
  27.     cin.tie(0);
  28.     cout.tie(0);
  29.     ios_base::sync_with_stdio(0);
  30. //---------------------------------------------------------------------------------------------------------
  31.     int n, m;
  32.     cin >> n >> m;
  33.     if (n != m && m != ((n*(n - 1)) / 2)) {
  34.         cout << "Impossible";
  35.         return 0;
  36.     }
  37.     set<pair<int, int>> ans;
  38.     cout << "Possible" << '\n';
  39.     if (n == m) {
  40.         for (int i = 1; i < n; i++) {
  41.             int j = i + 1;
  42.             ans.insert({min(i, j), max(i, j)});
  43.         }
  44.         ans.insert({1, n});
  45.     } else {
  46.         for (int i = 1; i <= n; i++) {
  47.             for (int j = 1; j <= n; j++) {
  48.                 if (i != j)
  49.                     ans.insert({min(i, j), max(i, j)});
  50.             }
  51.         }
  52.     }
  53.     for (auto x: ans) {
  54.         if (x.F == x.S) throw new exception;
  55.         cout << x.F << " " << x.S << endl;
  56.     }
  57.     return 0;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement