답안 #846771

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
846771 2023-09-08T12:00:58 Z MinaRagy06 Inside information (BOI21_servers) C++17
5 / 100
943 ms 2396 KB
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;

const int N = 4005;
vector<array<int, 2>> adj[N];

bool dfs(int i, int prvt, int par, int tar) {
    if (i == tar) return 1;
    bool ok = 0;
    for (auto [nxt, t] : adj[i]) {
        if (nxt == par) continue;
        if (prvt > t) {
            ok |= dfs(nxt, t, i, tar);
        }
    }
    return ok;
}
int dfs2(int i, int prvt, int par) {
    int ans = 1;
    for (auto [nxt, t] : adj[i]) {
        if (nxt == par) continue;
        if (prvt < t) {
            ans += dfs2(nxt, t, i);
        }
    }
    return ans;
}
int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n, q;
    cin >> n >> q;
    q += n - 1;
    for (int cur = 0; cur < q; cur++) {
        char t;
        int a, b;
        cin >> t >> a;
        if (t == 'S') {
            cin >> b;
            adj[a].push_back({b, cur});
            adj[b].push_back({a, cur});
        } else if (t == 'Q') {
            cin >> b;
            cout << (dfs(a, 1e9, -1, b)? "yes\n" : "no\n");
        } else {
            cout << dfs2(a, -1e9, -1) << '\n';
        }
    }
    return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 1624 KB Output is correct
2 Correct 25 ms 2392 KB Output is correct
3 Correct 174 ms 2388 KB Output is correct
4 Correct 26 ms 2380 KB Output is correct
5 Correct 24 ms 2384 KB Output is correct
6 Correct 932 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 1624 KB Output is correct
2 Correct 25 ms 2392 KB Output is correct
3 Correct 174 ms 2388 KB Output is correct
4 Correct 26 ms 2380 KB Output is correct
5 Correct 24 ms 2384 KB Output is correct
6 Correct 932 ms 2396 KB Output is correct
7 Correct 18 ms 1624 KB Output is correct
8 Correct 24 ms 1884 KB Output is correct
9 Correct 249 ms 2044 KB Output is correct
10 Correct 23 ms 2136 KB Output is correct
11 Correct 23 ms 2020 KB Output is correct
12 Correct 943 ms 2276 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 1616 KB Output is correct
2 Runtime error 1 ms 600 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 1616 KB Output is correct
2 Runtime error 1 ms 600 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 1624 KB Output is correct
2 Runtime error 1 ms 600 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 1624 KB Output is correct
2 Runtime error 1 ms 600 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 1624 KB Output is correct
2 Runtime error 1 ms 600 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 1624 KB Output is correct
2 Runtime error 1 ms 600 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 1628 KB Output is correct
2 Runtime error 1 ms 600 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 1628 KB Output is correct
2 Runtime error 1 ms 600 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 1624 KB Output is correct
2 Correct 25 ms 2280 KB Output is correct
3 Correct 187 ms 2320 KB Output is correct
4 Correct 23 ms 2392 KB Output is correct
5 Correct 24 ms 2384 KB Output is correct
6 Correct 923 ms 2392 KB Output is correct
7 Correct 26 ms 1616 KB Output is correct
8 Runtime error 1 ms 600 KB Execution killed with signal 11
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 1624 KB Output is correct
2 Correct 25 ms 2280 KB Output is correct
3 Correct 187 ms 2320 KB Output is correct
4 Correct 23 ms 2392 KB Output is correct
5 Correct 24 ms 2384 KB Output is correct
6 Correct 923 ms 2392 KB Output is correct
7 Correct 26 ms 1616 KB Output is correct
8 Runtime error 1 ms 600 KB Execution killed with signal 11
9 Halted 0 ms 0 KB -