Submission #696297

# Submission time Handle Problem Language Result Execution time Memory
696297 2023-02-06T07:30:38 Z Dan4Life Inside information (BOI21_servers) C++17
5 / 100
1973 ms 64856 KB
#include <bits/stdc++.h>
using namespace std;
const int mxN = (int)4010;

int n, k, pos[mxN];
int S[mxN][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][i]=1;
    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(int i = 1; i <= n; i++)
                S[x][i]=S[y][i]=S[x][i]|S[y][i];
        }
        else if(t=='Q'){
            cin >> y;
            if(1) cout << (S[x][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][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";
    }
}
# Verdict Execution time Memory Grader output
1 Correct 21 ms 1208 KB Output is correct
2 Correct 78 ms 64840 KB Output is correct
3 Correct 74 ms 64848 KB Output is correct
4 Correct 92 ms 64844 KB Output is correct
5 Correct 90 ms 64856 KB Output is correct
6 Correct 88 ms 64832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 1208 KB Output is correct
2 Correct 78 ms 64840 KB Output is correct
3 Correct 74 ms 64848 KB Output is correct
4 Correct 92 ms 64844 KB Output is correct
5 Correct 90 ms 64856 KB Output is correct
6 Correct 88 ms 64832 KB Output is correct
7 Correct 20 ms 1748 KB Output is correct
8 Correct 1973 ms 64148 KB Output is correct
9 Correct 1835 ms 64504 KB Output is correct
10 Correct 1926 ms 64424 KB Output is correct
11 Correct 1953 ms 64508 KB Output is correct
12 Correct 1801 ms 64696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 1340 KB Output is correct
2 Runtime error 47 ms 33220 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 20 ms 1340 KB Output is correct
2 Runtime error 47 ms 33220 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 20 ms 788 KB Output is correct
2 Runtime error 48 ms 33168 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 20 ms 788 KB Output is correct
2 Runtime error 48 ms 33168 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 19 ms 848 KB Output is correct
2 Runtime error 46 ms 33264 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 19 ms 848 KB Output is correct
2 Runtime error 46 ms 33264 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 19 ms 812 KB Output is correct
2 Runtime error 53 ms 33200 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 19 ms 812 KB Output is correct
2 Runtime error 53 ms 33200 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 19 ms 792 KB Output is correct
2 Correct 86 ms 63452 KB Output is correct
3 Correct 75 ms 63508 KB Output is correct
4 Correct 83 ms 63424 KB Output is correct
5 Correct 94 ms 63472 KB Output is correct
6 Correct 96 ms 63540 KB Output is correct
7 Correct 20 ms 828 KB Output is correct
8 Runtime error 49 ms 33236 KB Execution killed with signal 11
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 19 ms 792 KB Output is correct
2 Correct 86 ms 63452 KB Output is correct
3 Correct 75 ms 63508 KB Output is correct
4 Correct 83 ms 63424 KB Output is correct
5 Correct 94 ms 63472 KB Output is correct
6 Correct 96 ms 63540 KB Output is correct
7 Correct 20 ms 828 KB Output is correct
8 Runtime error 49 ms 33236 KB Execution killed with signal 11
9 Halted 0 ms 0 KB -