Submission #444411

# Submission time Handle Problem Language Result Execution time Memory
444411 2021-07-14T04:17:38 Z yungyao Inside information (BOI21_servers) C++17
5 / 100
3012 ms 384088 KB
using namespace std;
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <utility>
#include <memory.h>
#include <map>
#include <set>

typedef long long LL;
typedef pair<int,int> pii;

#define F first
#define S second
#define pb push_back
#define mkp make_pair
#define iter(x) x.begin(),x.end()

const int maxn = 12e4 + 100;
int n,k;

set <int> st[maxn];
int cnt[maxn];
void brutesolve(){
    for (int i=1;i<=n;++i) {st[i].insert(i); cnt[i] = 1;}

    for (int _=n+k-1;_--;){
        char o;
        cin >> o;
        if (o == 'S'){
            int u,v;

            cin >> u >> v;
            set <int> ele;
            for (auto i:st[u]) {ele.insert(i); ++cnt[i];}
            for (auto i:st[v]) {ele.insert(i); ++cnt[i];}
            st[u] = ele; st[v] = ele;
        }
        else if (o == 'Q'){
            int a,b;

            cin >> a >> b;
            cout << (st[a].find(b) != st[a].end() ? "yes\n" : "no\n");
        }
        else{
            int c;
            cin >> c;
            cout << cnt[c] << '\n';
        }
    }
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n >> k;

    if (n <= 4000) brutesolve();

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 29 ms 7148 KB Output is correct
2 Correct 45 ms 9032 KB Output is correct
3 Correct 300 ms 54496 KB Output is correct
4 Correct 41 ms 8644 KB Output is correct
5 Correct 42 ms 8476 KB Output is correct
6 Correct 2874 ms 384088 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 7148 KB Output is correct
2 Correct 45 ms 9032 KB Output is correct
3 Correct 300 ms 54496 KB Output is correct
4 Correct 41 ms 8644 KB Output is correct
5 Correct 42 ms 8476 KB Output is correct
6 Correct 2874 ms 384088 KB Output is correct
7 Correct 36 ms 7156 KB Output is correct
8 Correct 48 ms 8624 KB Output is correct
9 Correct 321 ms 66428 KB Output is correct
10 Correct 37 ms 8292 KB Output is correct
11 Correct 38 ms 8128 KB Output is correct
12 Correct 3012 ms 383768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 7272 KB Output is correct
2 Incorrect 4 ms 5964 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 30 ms 7272 KB Output is correct
2 Incorrect 4 ms 5964 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 29 ms 7176 KB Output is correct
2 Incorrect 3 ms 5964 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 29 ms 7176 KB Output is correct
2 Incorrect 3 ms 5964 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 30 ms 7160 KB Output is correct
2 Incorrect 3 ms 5968 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 30 ms 7160 KB Output is correct
2 Incorrect 3 ms 5968 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 36 ms 7196 KB Output is correct
2 Incorrect 3 ms 5964 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 36 ms 7196 KB Output is correct
2 Incorrect 3 ms 5964 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 36 ms 7168 KB Output is correct
2 Correct 44 ms 8964 KB Output is correct
3 Correct 288 ms 54516 KB Output is correct
4 Correct 55 ms 8644 KB Output is correct
5 Correct 43 ms 8476 KB Output is correct
6 Correct 2862 ms 383884 KB Output is correct
7 Correct 38 ms 7172 KB Output is correct
8 Incorrect 4 ms 5972 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 36 ms 7168 KB Output is correct
2 Correct 44 ms 8964 KB Output is correct
3 Correct 288 ms 54516 KB Output is correct
4 Correct 55 ms 8644 KB Output is correct
5 Correct 43 ms 8476 KB Output is correct
6 Correct 2862 ms 383884 KB Output is correct
7 Correct 38 ms 7172 KB Output is correct
8 Incorrect 4 ms 5972 KB Output isn't correct
9 Halted 0 ms 0 KB -