Submission #558438

# Submission time Handle Problem Language Result Execution time Memory
558438 2022-05-07T10:16:53 Z Yazan_Alattar Tenis (COI19_tenis) C++14
0 / 100
96 ms 13484 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define aint(x) x.begin(), x.end()
const int M = 100007;
const ll inf = 2e9;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
const double eps = 1e-6;
const int dx[] = {0, -1, 0, 1}, dy[] = {1, 0, -1, 0};
const int block = 320;

stack <int> st;
vector <int> adj[M], revadj[M];
int n, q, a[5][M], in[M],comp[M], comps;
bool vist[M];

void dfs(int node){
    vist[node] = 1;
    for(auto i : adj[node]) if(!vist[i]) dfs(i);

    st.push(node);
    return;
}

void revdfs(int node){
    vist[node] = 1;
    comp[node] = comps;

    for(auto i : revadj[node]) if(!vist[i]) revdfs(i);
    return;
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> q;
    for(int i = 1; i <= 3; ++i){
        for(int j = 1; j <= n; ++j){
            cin >> a[i][j];

            if(j > 1){
                adj[a[i][j - 1]].pb(a[i][j]);
                revadj[a[i][j]].pb(a[i][j - 1]);
            }
        }
    }

//    for(int i = 1; i <= n; ++i) if(!vist[i]) dfs(i);
//    for(int i = 1; i <= n; ++i) vist[i] = 0;
//
//    while(st.size()){
//        int node = st.top();
//        st.pop();
//        if(vist[node]) continue;
//
//        ++comps;
//        revdfs(node);
//    }
//
//    for(int i = 1; i <= n; ++i){
//        for(int j = 1; j < n; ++j){
//            int x = comp[a[i][j]], y = comp[a[i][j + 1]];
//            if(x != y) ++in[y];
//        }
//    }

    while(q--){
        int type;
        cin >> type;

        if(type == 1){
            int x;
            cin >> x;

            if(!in[comp[x]]) cout << "DA\n";
            else cout << "NE\n";
        }

        else{
            int x, y, z;
            cin >> x >> y >> z;
        }
    }
    return 0;
}

# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 4948 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 4948 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 4948 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 96 ms 13484 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 4948 KB Output isn't correct
2 Halted 0 ms 0 KB -