Submission #970624

# Submission time Handle Problem Language Result Execution time Memory
970624 2024-04-26T20:40:45 Z vladilius Inside information (BOI21_servers) C++17
10 / 100
62 ms 5836 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

struct FT{
    vector<int> bit;
    int n;
    FT(int ns){
        n = ns;
        bit.resize(n + 1);
    }
    void upd(int v, int k){
        while (v <= n){
            bit[v] += k;
            v |= (v + 1);
        }
    }
    void add(int l, int r, int k){
        upd(l, k);
        upd(r + 1, -k);
    }
    int get(int v){
        int out = 0;
        while (v > 0){
            out += bit[v];
            v = (v & (v + 1)) - 1;
        }
        return out;
    }
};

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int n, q; cin>>n>>q;
    q += (n - 1);
    
    vector<int> l(n + 1), r(n + 1);
    FT T(n);
    for (int i = 1; i <= n; i++){
        l[i] = r[i] = i;
        T.add(i, i, 1);
    }
    
    while (q--){
        char type; int a; cin>>type>>a;
        if (type == 'S'){
            int b; cin>>b;
            pii m = {min(l[a], l[b]), max(r[a], r[b])};
            T.add(l[a], r[a], -1);
            T.add(l[b], r[b], -1);
            l[a] = l[b] = m.first;
            r[a] = r[b] = m.second;
            T.add(m.first, m.second, 2);
        }
        else if (type == 'Q'){
            int d; cin>>d;
            if (l[a] <= d && d <= r[a]){
                cout<<"yes"<<"\n";
            }
            else {
                cout<<"no"<<"\n";
            }
        }
        else {
            cout<<T.get(a)<<"\n";
        }
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 860 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 860 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 856 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 856 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 17 ms 604 KB Output is correct
2 Correct 62 ms 5836 KB Output is correct
3 Correct 52 ms 5628 KB Output is correct
4 Correct 52 ms 5456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 604 KB Output is correct
2 Correct 62 ms 5836 KB Output is correct
3 Correct 52 ms 5628 KB Output is correct
4 Correct 52 ms 5456 KB Output is correct
5 Correct 17 ms 1624 KB Output is correct
6 Correct 48 ms 4976 KB Output is correct
7 Correct 46 ms 5204 KB Output is correct
8 Correct 53 ms 4720 KB Output is correct
9 Correct 46 ms 4692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 17 ms 600 KB Output is correct
2 Correct 56 ms 5632 KB Output is correct
3 Correct 53 ms 5476 KB Output is correct
4 Correct 51 ms 5456 KB Output is correct
5 Incorrect 20 ms 1628 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 17 ms 600 KB Output is correct
2 Correct 56 ms 5632 KB Output is correct
3 Correct 53 ms 5476 KB Output is correct
4 Correct 51 ms 5456 KB Output is correct
5 Incorrect 20 ms 1628 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -