Submission #749489

# Submission time Handle Problem Language Result Execution time Memory
749489 2023-05-28T05:48:06 Z GrindMachine Inside information (BOI21_servers) C++17
2.5 / 100
709 ms 524288 KB
// Om Namah Shivaya

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define pb push_back
#define endl '\n'
#define sz(a) a.size()
#define setbits(x) __builtin_popcountll(x)
#define ff first
#define ss second
#define conts continue
#define ceil2(x, y) ((x + y - 1) / (y))
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define yes cout << "yes" << endl
#define no cout << "no" << endl

#define rep(i, n) for(int i = 0; i < n; ++i)
#define rep1(i, n) for(int i = 1; i <= n; ++i)
#define rev(i, s, e) for(int i = s; i >= e; --i)
#define trav(i, a) for(auto &i : a)

template<typename T>
void amin(T &a, T b) {
    a = min(a, b);
}

template<typename T>
void amax(T &a, T b) {
    a = max(a, b);
}

#ifdef LOCAL
#include "debug.h"
#else
#define debug(x) 42
#endif

/*



*/

const int MOD = 1e9 + 7;
const int N = 1e5 + 5;
const int inf1 = int(1e9) + 5;
const ll inf2 = ll(1e18) + 5;

void solve(int test_case)
{
    ll n,k; cin >> n >> k;
    set<ll> st[n+5];
    rep1(i,n) st[i].insert(i);

    rep1(id,n+k-1){
        char ch; cin >> ch;
        if(ch == 'S'){
            ll u,v; cin >> u >> v;
            if(sz(st[v]) > sz(st[u])){
                swap(st[u], st[v]);
            }
            trav(x,st[v]){
                st[u].insert(x);
            }
            st[v] = st[u];
        }
        else if(ch == 'Q'){
            ll u,x; cin >> u >> x;
            if(st[u].count(x)) yes;
            else no;
        }
        else{
            assert(0);
        }
    }
}

int main()
{
    fastio;

    int t = 1;
    // cin >> t;

    rep1(i, t) {
        solve(i);
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 22 ms 1552 KB Output is correct
2 Correct 35 ms 3528 KB Output is correct
3 Correct 120 ms 48960 KB Output is correct
4 Correct 31 ms 3228 KB Output is correct
5 Correct 31 ms 2980 KB Output is correct
6 Correct 592 ms 378300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 1552 KB Output is correct
2 Correct 35 ms 3528 KB Output is correct
3 Correct 120 ms 48960 KB Output is correct
4 Correct 31 ms 3228 KB Output is correct
5 Correct 31 ms 2980 KB Output is correct
6 Correct 592 ms 378300 KB Output is correct
7 Runtime error 1 ms 596 KB Execution killed with signal 6
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 21 ms 1632 KB Output is correct
2 Runtime error 491 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 21 ms 1632 KB Output is correct
2 Runtime error 491 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 21 ms 1560 KB Output is correct
2 Correct 182 ms 34732 KB Output is correct
3 Correct 164 ms 34756 KB Output is correct
4 Runtime error 709 ms 524288 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 21 ms 1560 KB Output is correct
2 Correct 182 ms 34732 KB Output is correct
3 Correct 164 ms 34756 KB Output is correct
4 Runtime error 709 ms 524288 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 25 ms 1484 KB Output is correct
2 Runtime error 545 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 25 ms 1484 KB Output is correct
2 Runtime error 545 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 21 ms 1532 KB Output is correct
2 Correct 169 ms 34616 KB Output is correct
3 Correct 162 ms 34684 KB Output is correct
4 Runtime error 709 ms 524288 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 21 ms 1532 KB Output is correct
2 Correct 169 ms 34616 KB Output is correct
3 Correct 162 ms 34684 KB Output is correct
4 Runtime error 709 ms 524288 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 21 ms 1480 KB Output is correct
2 Correct 37 ms 3532 KB Output is correct
3 Correct 118 ms 48952 KB Output is correct
4 Correct 35 ms 3216 KB Output is correct
5 Correct 31 ms 3012 KB Output is correct
6 Correct 554 ms 378384 KB Output is correct
7 Correct 22 ms 1620 KB Output is correct
8 Runtime error 476 ms 524288 KB Execution killed with signal 9
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 21 ms 1480 KB Output is correct
2 Correct 37 ms 3532 KB Output is correct
3 Correct 118 ms 48952 KB Output is correct
4 Correct 35 ms 3216 KB Output is correct
5 Correct 31 ms 3012 KB Output is correct
6 Correct 554 ms 378384 KB Output is correct
7 Correct 22 ms 1620 KB Output is correct
8 Runtime error 476 ms 524288 KB Execution killed with signal 9
9 Halted 0 ms 0 KB -