답안 #760701

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
760701 2023-06-18T07:54:06 Z raysh07 늑대인간 (IOI18_werewolf) C++17
0 / 100
4000 ms 21452 KB
#include "werewolf.h"
#include <bits/stdc++.h>
using namespace std;

vector<int> check_validity(int n, vector<int> x, vector<int> y,
                                vector<int> s, vector<int> e,
                                vector<int> l, vector<int> r) {
    int q = s.size();
    vector<int> ans(q, 0);
    vector<vector<int>> adj(n);
    for (int i = 0; i < x.size(); i++) {
        adj[x[i]].push_back(y[i]);
        adj[y[i]].push_back(x[i]);
    }
  
    for (int i = 0; i < q; i++){
        vector <bool> vis(n, 0);
        queue <int> q;
        vis[s[i]] = true;
        q.push(s[i]);
        
        while (!q.empty()){
            int u = q.front(); q.pop();
            
            for (int v : adj[u]){
                if (vis[v]) continue;
                if ((u <= r[i] && v <= r[i]) || (u >= l[i] && v >= l[i])){
                    vis[v] = true;
                    q.push(v);
                }
            }
        }
        
        if (vis[e[i]]) ans[i] = 1;
        else ans[i] = 0;
    }
    return ans;
}

// int main(){
//     int n, m, q; cin >> n >> m >> q;
    
//     vector <int> x(m), y(m), s(q), e(q), l(q), r(q);
//     for (auto &z : x) cin >> z;
//     for (auto &z : y) cin >> z;
//     for (auto &z : s) cin >> z;
//     for (auto &z : e) cin >> z;
//     for (auto &z : l) cin >> z;
//     for (auto &z : r) cin >> z;
    
//     auto get = check_validity(n, x, y, s, e, l, r);
//     for (auto x : get) cout << x << "\n";
//     return 0;
// }

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:11:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     for (int i = 0; i < x.size(); i++) {
      |                     ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4069 ms 21452 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -