fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define pb push_back
  4. #define eb emplace_back
  5. #define mp make_pair
  6. #define pii pair<int,int>
  7. #define pll pair<long long , long long>
  8. #define vi vector<int>
  9. #define vpii vector<pii>
  10. #define SZ(x) ((int)(x.size()))
  11. #define fi first
  12. #define se second
  13. #define IN(x,y) ((y).find((x))!=(y).end())
  14. #define ALL(t) t.begin(),t.end()
  15. #define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
  16. #define REP(i,a,b) for(int (i)=(a);(i)<=(b);++i)
  17. #define REPD(i,a,b) for(int (i)=(a); (i)>=(b);--i)
  18. #define REMAX(a,b) (a)=max((a),(b));
  19. #define REMIN(a,b) (a)=min((a),(b));
  20. #define dem(x) __builtin_popcount(x)
  21. #define Mask(x) (1LL << (x))
  22. #define BIT(x, i) ((x) >> (i) & 1)
  23. #define ln '\n'
  24. #define io_faster ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  25.  
  26. const int INF = 1e9 , mod = 998244353;
  27.  
  28. template <class T1, class T2>
  29. inline T1 mul(T1 x, const T2 &k){ return (1LL * x * k) % mod; }
  30.  
  31. template < class T >
  32. void add(T &x, const T &y){ if ((x += y) >= mod) x -= mod; }
  33.  
  34. #define PROB "a"
  35. void file(){
  36. if(fopen(PROB".inp", "r")){
  37. freopen(PROB".inp","r",stdin);
  38. freopen(PROB".out","w",stdout);
  39. }
  40. }
  41. void sinh_(){
  42. // srand(time(0));
  43. // freopen(PROB".inp" , "w" , stdout);
  44. // int n;
  45. }
  46. typedef long long ll;
  47. const int N = 3e5 + 5;
  48.  
  49. pii e[N];
  50. vi adj[N];
  51. int n , m , sub , low[N] , num[N];
  52.  
  53. struct Dsu{
  54. int sz[N] , par[N];
  55. Dsu(int n = 0){
  56. REP(i, 1, n) par[i] = i, sz[i] = 1;
  57. }
  58. int root(int x){
  59. if (x == par[x]) return x;
  60. return par[x] = root(par[x]);
  61. }
  62. void unite(int u , int v){
  63. u = root(u) , v = root(v);
  64. if (u == v) return;
  65. if (sz[u] < sz[v]) swap(u, v);
  66. sz[u] += sz[v] , par[v] = u;
  67. return;
  68. }
  69. } dsu;
  70.  
  71.  
  72. void readip(){
  73. cin >> sub >> n >> m;
  74. dsu = Dsu(n);
  75. REP(i, 1, m){
  76. int u , v; cin >> u >> v;
  77. e[i] = mp(u, v);
  78. adj[u].eb(i);
  79. adj[v].eb(i);
  80. dsu.unite(u , v);
  81. }
  82. }
  83.  
  84. void solve(){
  85.  
  86. }
  87.  
  88. int main(){
  89. sinh_();
  90. io_faster
  91. file();
  92. int t = 1;
  93. // cin >> t;
  94. while (t--){
  95. readip();
  96. solve();
  97. }
  98. }
  99.  
Success #stdin #stdout 0.01s 16520KB
stdin
1
6 7
1 2
2 3
3 1
3 4
4 5
5 6
6 4
stdout
Standard output is empty