답안 #970940

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
970940 2024-04-27T14:30:25 Z kl0989e Inside information (BOI21_servers) C++17
5 / 100
1036 ms 524288 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define fi first
#define se second
#define pb push_back
#define vi vector<int>
#define pi pair<int, int>
#define all(x) (x).begin(),(x).end()

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,k;
    cin >> n >> k;
    vector<unordered_set<int>> servers(n);
    vi count(n,1);
    for (int i=0; i<n; i++) {
        servers[i].insert(i);
    }
    char c;
    int a,b;
    for (int i=0; i<k+n-1; i++) {
        cin >> c;
        if (c=='S') {//S a b means servers 𝑎 and 𝑏 Share all their data.
            cin >> a >> b;
            a--;
            b--;
            if (servers[a].size()<servers[b].size()) {
                swap(a,b);
            }
            servers[a].merge(servers[b]);
            servers[b]=servers[a];
            for (auto aa:servers[a]) {
                count[aa]++;
            }
        }
        else if (c=='Q') {//Q a d means you Query whether server 𝑎 currently stores data chunk 𝑑.
            cin >> a >> b;
            a--;
            b--;
            if (servers[a].count(b)) {
                cout << "yes\n";
            }
            else {
                cout << "no\n";
            }
        }
        else {//C d means you query the Count (number) of servers that currently store data chunk 𝑑.
            cin >> a;
            a--;
            cout << count[a] << '\n';
        }
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 1624 KB Output is correct
2 Correct 24 ms 3712 KB Output is correct
3 Correct 85 ms 44284 KB Output is correct
4 Correct 22 ms 3412 KB Output is correct
5 Correct 24 ms 3200 KB Output is correct
6 Correct 614 ms 348124 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 1624 KB Output is correct
2 Correct 24 ms 3712 KB Output is correct
3 Correct 85 ms 44284 KB Output is correct
4 Correct 22 ms 3412 KB Output is correct
5 Correct 24 ms 3200 KB Output is correct
6 Correct 614 ms 348124 KB Output is correct
7 Correct 16 ms 1628 KB Output is correct
8 Correct 21 ms 3400 KB Output is correct
9 Correct 102 ms 56476 KB Output is correct
10 Correct 20 ms 3216 KB Output is correct
11 Correct 21 ms 2908 KB Output is correct
12 Correct 581 ms 347988 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 1612 KB Output is correct
2 Runtime error 1036 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 1612 KB Output is correct
2 Runtime error 1036 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 1696 KB Output is correct
2 Correct 155 ms 40940 KB Output is correct
3 Correct 172 ms 41040 KB Output is correct
4 Runtime error 420 ms 524288 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 1696 KB Output is correct
2 Correct 155 ms 40940 KB Output is correct
3 Correct 172 ms 41040 KB Output is correct
4 Runtime error 420 ms 524288 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 1660 KB Output is correct
2 Runtime error 508 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 1660 KB Output is correct
2 Runtime error 508 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 1624 KB Output is correct
2 Correct 159 ms 40872 KB Output is correct
3 Correct 150 ms 40976 KB Output is correct
4 Runtime error 424 ms 524288 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 1624 KB Output is correct
2 Correct 159 ms 40872 KB Output is correct
3 Correct 150 ms 40976 KB Output is correct
4 Runtime error 424 ms 524288 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 1616 KB Output is correct
2 Correct 26 ms 3780 KB Output is correct
3 Correct 86 ms 44392 KB Output is correct
4 Correct 22 ms 3412 KB Output is correct
5 Correct 22 ms 3412 KB Output is correct
6 Correct 565 ms 348180 KB Output is correct
7 Correct 16 ms 1628 KB Output is correct
8 Runtime error 790 ms 524288 KB Execution killed with signal 9
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 1616 KB Output is correct
2 Correct 26 ms 3780 KB Output is correct
3 Correct 86 ms 44392 KB Output is correct
4 Correct 22 ms 3412 KB Output is correct
5 Correct 22 ms 3412 KB Output is correct
6 Correct 565 ms 348180 KB Output is correct
7 Correct 16 ms 1628 KB Output is correct
8 Runtime error 790 ms 524288 KB Execution killed with signal 9
9 Halted 0 ms 0 KB -