Advertisement
Guest User

1

a guest
Nov 13th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.01 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. //int parent[300001], a[300001];
  6. vector < pair < int, int > > minyc;
  7. map <pair <int, int>, pair <int, int> > a, b;
  8.  
  9. int main()
  10. {
  11.     int i, k, n, kol, v1, v2, q;
  12.     char bu;
  13.     cin >> n >> q;
  14.     for (int t = 0; t < q; t++)
  15.     {
  16.         cin >> bu;
  17.         if (bu == '+')
  18.         {
  19.             cin >> v1 >> v2;
  20.             a[{v2,v1}].insert({v1, v2});
  21.             a[{v1,v2}].insert({v2, v1});
  22.         }
  23.         if (bu == '-')
  24.         {
  25.             cin >> v1 >> v2;
  26.             b[{v2, v1}].insert({v1, v2});
  27.             b[{v1, v2}].insert({v2, v1});
  28.         }
  29.         if (bu == '?')
  30.         {
  31.             cin >> v1 >> v2;
  32.             if (a[{v1,v2}].count({v1, v2}))
  33.             {
  34.                 cout << "+\n";
  35.                 continue;
  36.             }
  37.             if (b[{v1, v2}].count({v1, v2}))
  38.             {
  39.                 cout << "-\n";
  40.                 continue;
  41.             }
  42.             cout << "?\n";
  43.         }
  44.     }
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement