Submission #402387

# Submission time Handle Problem Language Result Execution time Memory
402387 2021-05-11T16:11:08 Z doowey Inside information (BOI21_servers) C++14
2.5 / 100
3500 ms 11616 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int N = 120100;
const int M = N * 2;
vector<pii> T[N];

int bruh[M];

bool chk(int node, int par, int target, int las){
    if(node == target) return true;
    for(auto x : T[node]){
        if(x.fi == par || x.se < las) continue;
        if(chk(x.fi, node, target, x.se))
            return true;
    }
    return false;
}


int main(){
    fastIO;
    int n, q;
    cin >> n >> q;
    char typ;
    int xx, yy;
    bool sol;
    for(int iq = 1; iq <= n + q - 1; iq ++ ){
        cin >> typ;
        if(typ == 'S'){
            cin >> xx >> yy;
            T[xx].push_back(mp(yy, iq));
            T[yy].push_back(mp(xx, iq));
        }
        else{
            cin >> xx >> yy;
            sol = chk(yy, -1, xx, 0);
            if(sol == true){
                bruh[iq] = -1;
            }
            else{
                bruh[iq] = -2;
            }
        }
    }
    for(int i = 1; i <= n + q - 1; i ++ ){
        if(bruh[i] == 0) continue;
        if(bruh[i] == -1){
            cout << "yes\n";
        }
        else if(bruh[i] == -2){
            cout << "no\n";
        }
        else{
            cout << bruh[i] << "\n";
        }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 33 ms 3908 KB Output is correct
2 Correct 42 ms 5488 KB Output is correct
3 Correct 121 ms 5472 KB Output is correct
4 Correct 39 ms 5532 KB Output is correct
5 Correct 40 ms 5388 KB Output is correct
6 Correct 1168 ms 5564 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 3908 KB Output is correct
2 Correct 42 ms 5488 KB Output is correct
3 Correct 121 ms 5472 KB Output is correct
4 Correct 39 ms 5532 KB Output is correct
5 Correct 40 ms 5388 KB Output is correct
6 Correct 1168 ms 5564 KB Output is correct
7 Incorrect 11 ms 4024 KB Extra information in the output file
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 33 ms 3988 KB Output is correct
2 Execution timed out 3566 ms 6424 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 33 ms 3988 KB Output is correct
2 Execution timed out 3566 ms 6424 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 29 ms 3860 KB Output is correct
2 Correct 108 ms 11520 KB Output is correct
3 Correct 98 ms 11488 KB Output is correct
4 Execution timed out 3572 ms 9932 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Correct 29 ms 3860 KB Output is correct
2 Correct 108 ms 11520 KB Output is correct
3 Correct 98 ms 11488 KB Output is correct
4 Execution timed out 3572 ms 9932 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Correct 30 ms 3896 KB Output is correct
2 Execution timed out 3576 ms 10896 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 30 ms 3896 KB Output is correct
2 Execution timed out 3576 ms 10896 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 29 ms 3892 KB Output is correct
2 Correct 109 ms 11460 KB Output is correct
3 Correct 107 ms 11616 KB Output is correct
4 Execution timed out 3606 ms 9988 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 29 ms 3892 KB Output is correct
2 Correct 109 ms 11460 KB Output is correct
3 Correct 107 ms 11616 KB Output is correct
4 Execution timed out 3606 ms 9988 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 33 ms 3920 KB Output is correct
2 Correct 42 ms 5504 KB Output is correct
3 Correct 120 ms 5532 KB Output is correct
4 Correct 39 ms 5444 KB Output is correct
5 Correct 41 ms 5368 KB Output is correct
6 Correct 1166 ms 5600 KB Output is correct
7 Correct 34 ms 4856 KB Output is correct
8 Execution timed out 3593 ms 6056 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 33 ms 3920 KB Output is correct
2 Correct 42 ms 5504 KB Output is correct
3 Correct 120 ms 5532 KB Output is correct
4 Correct 39 ms 5444 KB Output is correct
5 Correct 41 ms 5368 KB Output is correct
6 Correct 1166 ms 5600 KB Output is correct
7 Correct 34 ms 4856 KB Output is correct
8 Execution timed out 3593 ms 6056 KB Time limit exceeded
9 Halted 0 ms 0 KB -