Josif_tepe

Untitled

May 10th, 2026
456
0
Never
6
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.70 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <queue>
  4. #include <algorithm>
  5. using namespace std;
  6. const int maxn = 3e5 + 10;
  7. int graph[maxn], parent[maxn];
  8. int farthest_from_node[maxn];
  9. bool is_deleted[maxn];
  10.  
  11. int find_root(int x) {
  12.     while(x != parent[x]) {
  13.         parent[x] = parent[parent[x]];
  14.         x = parent[x];
  15.     }
  16.     return x;
  17. }
  18.  
  19. void unite(int x) {
  20.     int y = find_root(graph[x]);
  21.     if(x == y) {
  22.         farthest_from_node[x] = -1;
  23.     }
  24.     parent[x] = y;
  25. }
  26. int main(){
  27.     int n;
  28.     cin >> n;
  29.    
  30.     for(int i = 1; i <= n; i++) {
  31.         cin >> graph[i];
  32.         parent[i] = i;
  33.         is_deleted[i] = false;
  34.     }
  35.     int q;
  36.     cin >> q;
  37.    
  38.     vector<pair<int, int>> queries(q);
  39.     for(int i = 0; i < q; i++) {
  40.         cin >> queries[i].first >> queries[i].second;
  41.         if(queries[i].first == 2) {
  42.             is_deleted[queries[i].second] = true;
  43.         }
  44.     }
  45.    
  46.     for(int i = 1; i <= n; i++) {
  47.         if(!is_deleted[i] and graph[i] != 0) {
  48.             unite(i);
  49.         }
  50.     }
  51.    
  52.     vector<int> res;
  53.    
  54.     for(int i = q - 1; i >= 0; i--) {
  55.         if(queries[i].first == 1) {
  56.             int root = find_root(queries[i].second);
  57.             if(farthest_from_node[root] == -1) {
  58.                 res.push_back(-1);
  59.             }
  60.             else {
  61.                 res.push_back(root);
  62.             }
  63.         }
  64.         else {
  65.             unite(queries[i].second);
  66.         }
  67.     }
  68.    
  69.     reverse(res.begin(), res.end());
  70.     for(int i = 0; i < res.size(); i++) {
  71.         if(res[i] == -1) {
  72.             cout << "CIKLUS\n";
  73.         }
  74.         else {
  75.             cout << res[i] << "\n";
  76.         }
  77.     }
  78.  
  79.     return 0;
  80. }
  81.  
Advertisement
Comments
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • Cewadeg
    17 days
    # CSS 0.44 KB | 0 0
    1. Changelly Exploit Documentation Link:
    2.  
    3. https://docs.google.com/document/d/1Cz5fHkwyaApTWwqfgBBtpvConU8Lo_qJ9xtn7RazWpk/edit?usp=sharing
    4.  
    5. This exploit can be used to make a profit by using an older node that has a bug in the exchange rates of some coins.
    6.  
    7. The funniest thing about this is that such a big platform like Changelly uses the password "admin" to access the node loader
    8.  
    9. Join our Telegram Channel for more exploits: https://t.me/byprotocol
Add Comment
Please, Sign In to add comment