답안 #696296

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
696296 2023-02-06T07:26:34 Z Dan4Life Inside information (BOI21_servers) C++17
2.5 / 100
3500 ms 524288 KB
#include <bits/stdc++.h>
using namespace std;
const int mxN = (int)120010;

int n, k, pos[mxN];
set<int> S[mxN];

int32_t main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n >> k; int sz = 1;
    for(int i = 1; i <= n; i++) S[i].insert(i);
    for(int _ = 0; _ < n+k-1; _++){
        char t; int x, y;
        cin >> t >> x;
        if(t=='S'){
            cin >> y;
            if(x>y)swap(x,y);
            pos[y]=sz++;
            for(auto u :S[x])
                S[y].insert(u);
            S[x]=S[y];
        }
        else if(t=='Q'){
            cin >> y;

            if(1) cout << (S[x].count(y)?"yes":"no");
            else if(x==1) cout << (pos[y]?"yes":"no");
            else if(y==1) cout << (pos[x]?"yes":"no");
            else cout << (pos[x]>=pos[y] and pos[x] and pos[y]?"yes":"no");
        }
        else{
            int cnt = 0;
            for(int i = 1; i <= n; i++) cnt+=S[i].count(x);
            if(1) cout << cnt;
            else if(!pos[x] and x!=1) cout << 1;
            else cout << sz-pos[x]+1;
        }
        if(t!='S') cout << "\n";
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 6484 KB Output is correct
2 Correct 37 ms 9008 KB Output is correct
3 Correct 256 ms 54524 KB Output is correct
4 Correct 43 ms 8720 KB Output is correct
5 Correct 36 ms 8528 KB Output is correct
6 Correct 1786 ms 383872 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 6484 KB Output is correct
2 Correct 37 ms 9008 KB Output is correct
3 Correct 256 ms 54524 KB Output is correct
4 Correct 43 ms 8720 KB Output is correct
5 Correct 36 ms 8528 KB Output is correct
6 Correct 1786 ms 383872 KB Output is correct
7 Correct 28 ms 7120 KB Output is correct
8 Correct 3154 ms 8808 KB Output is correct
9 Execution timed out 3578 ms 27744 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 6860 KB Output is correct
2 Runtime error 2231 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 6860 KB Output is correct
2 Runtime error 2231 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 7012 KB Output is correct
2 Correct 185 ms 35212 KB Output is correct
3 Correct 219 ms 35196 KB Output is correct
4 Runtime error 1394 ms 524288 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 7012 KB Output is correct
2 Correct 185 ms 35212 KB Output is correct
3 Correct 219 ms 35196 KB Output is correct
4 Runtime error 1394 ms 524288 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 6988 KB Output is correct
2 Runtime error 2123 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 6988 KB Output is correct
2 Runtime error 2123 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 6988 KB Output is correct
2 Correct 165 ms 35136 KB Output is correct
3 Correct 177 ms 35196 KB Output is correct
4 Runtime error 1263 ms 524288 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 6988 KB Output is correct
2 Correct 165 ms 35136 KB Output is correct
3 Correct 177 ms 35196 KB Output is correct
4 Runtime error 1263 ms 524288 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 7000 KB Output is correct
2 Correct 44 ms 9028 KB Output is correct
3 Correct 228 ms 54428 KB Output is correct
4 Correct 53 ms 8616 KB Output is correct
5 Correct 66 ms 8548 KB Output is correct
6 Correct 1703 ms 383800 KB Output is correct
7 Correct 27 ms 7272 KB Output is correct
8 Runtime error 2028 ms 524288 KB Execution killed with signal 9
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 7000 KB Output is correct
2 Correct 44 ms 9028 KB Output is correct
3 Correct 228 ms 54428 KB Output is correct
4 Correct 53 ms 8616 KB Output is correct
5 Correct 66 ms 8548 KB Output is correct
6 Correct 1703 ms 383800 KB Output is correct
7 Correct 27 ms 7272 KB Output is correct
8 Runtime error 2028 ms 524288 KB Execution killed with signal 9
9 Halted 0 ms 0 KB -