Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define TRACE(x) x
- #define WATCH(x) TRACE( cout << #x" = " << x << endl)
- #define PRINT(x) TRACE(printf(x))
- #define WATCHR(a, b) TRACE( for(auto c = a; c != b;) cout << *(c++) << " "; cout << endl)
- #define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end()); } )
- #define all(v) (v).begin(), (v).end()
- #define rall(v) (v).rbegin(), (v).rend()
- #define sz(v) (int) (v).size()
- #define rep(i,a,b) for(int (i) = (a); (i) < (b); ++(i))
- #define pb push_back
- #define mp make_pair
- using ll = long long;
- using vi = vector<int>;
- using pii = pair<int, int>;
- using pll = pair<ll, ll>;
- constexpr int inf = 0x3f3f3f3f;
- constexpr ll MOD = 1000000007LL;
- constexpr double tol = 1e-8;
- void buff() { ios::sync_with_stdio( false ); cin.tie(nullptr); }
- vector< vector<int> > graph;
- vector< int > mark;
- int current_label = 0;
- void explore( int node, int label )
- {
- mark[node] = label;
- for( const int& x : graph[node] )
- {
- if( mark[x] == -1 ) explore(x, label);
- }
- }
- int main()
- {
- buff();
- int n, m, p;
- cin >> n >> m >> p;
- graph.resize(n);
- mark.assign(n, -1);
- for(int i = 0; i < m; ++i)
- {
- int a, b;
- cin >> a >> b;
- --a; --b;
- // grafo com arestas bi-direcionais
- graph[a].push_back( b );
- graph[b].push_back( a );
- }
- for(int i = 0; i < n; ++i)
- {
- if( mark[i] == -1 ) explore(i, ++current_label );
- }
- for(int i = 0; i < p; ++i)
- {
- int a, b;
- cin >> a >> b;
- --a; --b;
- if( mark[a] == mark[b] ) cout << "Lets que lets" << endl;
- else cout << "Deu ruim" << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement