답안 #1024203

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1024203 2024-07-15T16:05:47 Z ksu2009en 늑대인간 (IOI18_werewolf) C++17
15 / 100
4000 ms 26484 KB
#include "werewolf.h"
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <bitset>
#include <cstring>
#include <unordered_map>

using namespace std;
typedef int ll;

vector<ll> d[200007];

bool used1[200007], used2[200007];

ll lim = 0;

void dfs1(ll v){
    if(v < lim)
        return;
    
    used1[v] = true;
    for(auto i: d[v]){
        if(!used1[i] && i >= lim)
            dfs1(i);
    }
}

void dfs2(ll v){
    if(v > lim)
        return;
    
    used2[v] = true;
    for(auto i: d[v]){
        if(!used2[i] && i <= lim)
            dfs2(i);
    }
}

std::vector<int> check_validity(int n, std::vector<int> x, std::vector<int> y,
                                std::vector<int> s, std::vector<int> e,
                                std::vector<int> l, std::vector<int> r) {
    
    ll q = l.size();
    
    for(int i = 0; i < x.size(); i++){
        d[x[i]].push_back(y[i]);
        d[y[i]].push_back(x[i]);
    }
    
    vector<int> ans;
    
    for(int i = 0; i < q; i++){
        lim = l[i];
        
        dfs1(s[i]);
        lim = r[i];
        dfs2(e[i]);
        
        int res = 0;
        for(int j = 0; j < n; j++){
            if(used1[j] && used2[j]){
                res = 1;
            }
            
            used1[j] = used2[j] = 0;
        }
        
        ans.push_back(res);
    }
    
    return ans;
}
/*
 6 6 3
 0 3
 3 1
 3 4
 1 2
 2 5
 1 5
 4 2 1 2
 4 2 2 2
 5 4 3 4
 
 */

/*
 6 6 1
 0 3
 3 1
 3 4
 1 2
 2 5
 1 5
 4 2 1 2
 
 4 2 2 2
 5 4 3 4
 */

Compilation message

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:57:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |     for(int i = 0; i < x.size(); i++){
      |                    ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5212 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 2 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 5212 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 2 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 160 ms 5724 KB Output is correct
11 Correct 69 ms 5704 KB Output is correct
12 Correct 22 ms 5724 KB Output is correct
13 Correct 191 ms 5720 KB Output is correct
14 Correct 82 ms 5704 KB Output is correct
15 Correct 172 ms 5844 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4040 ms 26484 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5212 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 2 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 160 ms 5724 KB Output is correct
11 Correct 69 ms 5704 KB Output is correct
12 Correct 22 ms 5724 KB Output is correct
13 Correct 191 ms 5720 KB Output is correct
14 Correct 82 ms 5704 KB Output is correct
15 Correct 172 ms 5844 KB Output is correct
16 Execution timed out 4040 ms 26484 KB Time limit exceeded
17 Halted 0 ms 0 KB -