Submission #314318

# Submission time Handle Problem Language Result Execution time Memory
314318 2020-10-19T16:53:14 Z amunduzbaev Werewolf (IOI18_werewolf) C++14
15 / 100
311 ms 43492 KB
//#include "grader.cpp"
#include "werewolf.h"
#include <bits/stdc++.h>
#define pb(n) push_back(n)
using namespace std;
const int N=3005;
vector<vector<int>>edges;
bool reached=0;
int l, h, used1[N],used2[N];
void dfs1(int v){
    used1[v]=1;
    for(auto x:edges[v]){
        if(x<l||used1[x]) continue;
        dfs1(x);
    }
}
void dfs2(int v){
    used2[v]=1;
    if(used1[v]&&used2[v]) {
        reached=1;
        return;
    }
    if(reached) return;
    for(auto x:edges[v]){
        if(x>h||used2[x]) continue;
        if(reached) return;
        dfs2(x);
    }
}
vector<int> check_validity(int n, vector<int> X, vector<int> Y, vector<int> s, vector<int> e, vector<int> low, vector<int> high) {
    int q=s.size(),m=X.size();
    edges.resize(n);
    for(int i=0;i<m;i++){
        edges[X[i]].pb(Y[i]);
        edges[Y[i]].pb(X[i]);
    }
    vector<int>a(q);
    for(int i=0;i<q;i++){
        l=low[i], h=high[i];
        if(s[i]>=l)
        dfs1(s[i]);
        reached=0;
        if(e[i]<=h)
        dfs2(e[i]);
        a[i]=reached;
        memset(used1,0,sizeof(used1));
        memset(used2,0,sizeof(used2));
    }
    return a;
}

/*

6 6 3
5 1
1 2
1 3
3 4
3 0
5 2
4 2 1 2
4 2 2 2
5 4 3 4

*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 160 ms 888 KB Output is correct
11 Correct 90 ms 888 KB Output is correct
12 Correct 15 ms 896 KB Output is correct
13 Correct 152 ms 768 KB Output is correct
14 Correct 106 ms 768 KB Output is correct
15 Correct 224 ms 896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 311 ms 43492 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 160 ms 888 KB Output is correct
11 Correct 90 ms 888 KB Output is correct
12 Correct 15 ms 896 KB Output is correct
13 Correct 152 ms 768 KB Output is correct
14 Correct 106 ms 768 KB Output is correct
15 Correct 224 ms 896 KB Output is correct
16 Runtime error 311 ms 43492 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Halted 0 ms 0 KB -