Submission #846794

# Submission time Handle Problem Language Result Execution time Memory
846794 2023-09-08T12:44:48 Z Ahmed57 Inside information (BOI21_servers) C++17
5 / 100
3500 ms 210600 KB
#include <bits/stdc++.h>
using namespace std;

int main(){
    int n,q;cin>>n>>q;
    vector<int> v[n+1];
    for(int i = 1;i<=n;i++)v[i].push_back(i);
    int cnt[n+1] = {0};
    for(int i = 1;i<=n;i++)cnt[i] = 1;
    q+=n-1;
    while(q--){
        char s;cin>>s;
        if(s=='S'){
            int a,b;cin>>a>>b;
            set<int> x;
            for(auto i:v[a]){x.insert(i);cnt[i]--;}
            for(auto i:v[b]){x.insert(i);cnt[i]--;}
            v[a].clear();v[b].clear();
            for(auto i:x){
                v[a].push_back(i);
                v[b].push_back(i);
                cnt[i]+=2;
            }
        }else if(s=='C'){
            int a;cin>>a;
            cout<<cnt[a]<<endl;
        }else{
            int a,b;cin>>a>>b;
            auto it = lower_bound(v[a].begin(),v[a].end(),b)-v[a].begin();
            if(it==v[a].size()||v[a][it]!=b)cout<<"no\n";
            else cout<<"yes\n";
        }
    }
}

Compilation message

servers.cpp: In function 'int main()':
servers.cpp:30:18: warning: comparison of integer expressions of different signedness: 'long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |             if(it==v[a].size()||v[a][it]!=b)cout<<"no\n";
      |                ~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 169 ms 592 KB Output is correct
2 Correct 186 ms 1104 KB Output is correct
3 Correct 283 ms 6860 KB Output is correct
4 Correct 187 ms 1104 KB Output is correct
5 Correct 184 ms 1016 KB Output is correct
6 Correct 835 ms 41248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 169 ms 592 KB Output is correct
2 Correct 186 ms 1104 KB Output is correct
3 Correct 283 ms 6860 KB Output is correct
4 Correct 187 ms 1104 KB Output is correct
5 Correct 184 ms 1016 KB Output is correct
6 Correct 835 ms 41248 KB Output is correct
7 Correct 171 ms 596 KB Output is correct
8 Correct 177 ms 1028 KB Output is correct
9 Correct 275 ms 8656 KB Output is correct
10 Correct 177 ms 952 KB Output is correct
11 Correct 185 ms 848 KB Output is correct
12 Correct 794 ms 41552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 169 ms 612 KB Output is correct
2 Execution timed out 3556 ms 192556 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 169 ms 612 KB Output is correct
2 Execution timed out 3556 ms 192556 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 170 ms 592 KB Output is correct
2 Correct 331 ms 12808 KB Output is correct
3 Correct 316 ms 12832 KB Output is correct
4 Execution timed out 3537 ms 210600 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 170 ms 592 KB Output is correct
2 Correct 331 ms 12808 KB Output is correct
3 Correct 316 ms 12832 KB Output is correct
4 Execution timed out 3537 ms 210600 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 169 ms 592 KB Output is correct
2 Execution timed out 3531 ms 141096 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 169 ms 592 KB Output is correct
2 Execution timed out 3531 ms 141096 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 174 ms 756 KB Output is correct
2 Correct 308 ms 12684 KB Output is correct
3 Correct 323 ms 12824 KB Output is correct
4 Execution timed out 3541 ms 209740 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 174 ms 756 KB Output is correct
2 Correct 308 ms 12684 KB Output is correct
3 Correct 323 ms 12824 KB Output is correct
4 Execution timed out 3541 ms 209740 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 171 ms 740 KB Output is correct
2 Correct 184 ms 1020 KB Output is correct
3 Correct 259 ms 6712 KB Output is correct
4 Correct 182 ms 1104 KB Output is correct
5 Correct 181 ms 848 KB Output is correct
6 Correct 845 ms 41228 KB Output is correct
7 Correct 167 ms 592 KB Output is correct
8 Execution timed out 3547 ms 187924 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 171 ms 740 KB Output is correct
2 Correct 184 ms 1020 KB Output is correct
3 Correct 259 ms 6712 KB Output is correct
4 Correct 182 ms 1104 KB Output is correct
5 Correct 181 ms 848 KB Output is correct
6 Correct 845 ms 41228 KB Output is correct
7 Correct 167 ms 592 KB Output is correct
8 Execution timed out 3547 ms 187924 KB Time limit exceeded
9 Halted 0 ms 0 KB -