답안 #1026156

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1026156 2024-07-17T16:06:20 Z mariza 늑대인간 (IOI18_werewolf) C++14
15 / 100
4000 ms 38552 KB
#include <bits/stdc++.h>
#include "werewolf.h"
using namespace std;

typedef long long ll;

vector<ll> g[200000];
ll s, e, l, r;

bool vis[200000][2];
void dfs(ll curr, bool w){
    if(vis[curr][w]) return;
    vis[curr][w]=true;

    bool ans=false;
    if(l<=curr && curr<=r && !w) dfs(curr,true);

    for(auto nxt:g[curr]){
        if(!w && l<=nxt) dfs(nxt,false);
        else if(w && nxt<=r) dfs(nxt,true);
    }
}

vector<int> check_validity(int N, vector<int> X, vector<int> Y, vector<int> S, vector<int> E, vector<int> L, vector<int> R) {
    for(ll i=0; i<X.size(); i++){
        g[X[i]].push_back(Y[i]);
        g[Y[i]].push_back(X[i]);
    }

    ll Q = S.size();
    vector<int> a;
    for(ll i=0; i<Q; i++){
        s=S[i];
        e=E[i];
        l=L[i];
        r=R[i];

        for(ll j=0; j<N; j++){
            vis[j][0]=false;
            vis[j][1]=false;
        }
        dfs(s,false);
        a.push_back(vis[e][1]);
    }
    return a;
}

Compilation message

werewolf.cpp: In function 'void dfs(ll, bool)':
werewolf.cpp:15:10: warning: unused variable 'ans' [-Wunused-variable]
   15 |     bool ans=false;
      |          ^~~
werewolf.cpp: In function 'std::vector<int> check_validity(int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
werewolf.cpp:25:18: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for(ll i=0; i<X.size(); i++){
      |                 ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5208 KB Output is correct
2 Correct 1 ms 5212 KB Output is correct
3 Correct 1 ms 5212 KB Output is correct
4 Correct 1 ms 5212 KB Output is correct
5 Correct 1 ms 5212 KB Output is correct
6 Correct 1 ms 5212 KB Output is correct
7 Correct 1 ms 5212 KB Output is correct
8 Correct 1 ms 5212 KB Output is correct
9 Correct 1 ms 5212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5208 KB Output is correct
2 Correct 1 ms 5212 KB Output is correct
3 Correct 1 ms 5212 KB Output is correct
4 Correct 1 ms 5212 KB Output is correct
5 Correct 1 ms 5212 KB Output is correct
6 Correct 1 ms 5212 KB Output is correct
7 Correct 1 ms 5212 KB Output is correct
8 Correct 1 ms 5212 KB Output is correct
9 Correct 1 ms 5212 KB Output is correct
10 Correct 227 ms 5744 KB Output is correct
11 Correct 133 ms 5700 KB Output is correct
12 Correct 16 ms 5724 KB Output is correct
13 Correct 199 ms 5756 KB Output is correct
14 Correct 122 ms 5724 KB Output is correct
15 Correct 189 ms 5880 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4032 ms 38552 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5208 KB Output is correct
2 Correct 1 ms 5212 KB Output is correct
3 Correct 1 ms 5212 KB Output is correct
4 Correct 1 ms 5212 KB Output is correct
5 Correct 1 ms 5212 KB Output is correct
6 Correct 1 ms 5212 KB Output is correct
7 Correct 1 ms 5212 KB Output is correct
8 Correct 1 ms 5212 KB Output is correct
9 Correct 1 ms 5212 KB Output is correct
10 Correct 227 ms 5744 KB Output is correct
11 Correct 133 ms 5700 KB Output is correct
12 Correct 16 ms 5724 KB Output is correct
13 Correct 199 ms 5756 KB Output is correct
14 Correct 122 ms 5724 KB Output is correct
15 Correct 189 ms 5880 KB Output is correct
16 Execution timed out 4032 ms 38552 KB Time limit exceeded
17 Halted 0 ms 0 KB -