답안 #1066918

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1066918 2024-08-20T08:47:04 Z Muhammad_Aneeq 늑대인간 (IOI18_werewolf) C++17
컴파일 오류
0 ms 0 KB
#include <vector>
#include <queue>
#include <iostream>
using namespace std;
int const N=2e5+10;
vector<int>nei[N]={};
bool reach[N]={};
bool bfs(int u,int v,int l,int r)
{
    queue<pair<int,int>>Q;
    Q.push({0,u});
    reach[u]=1;
    while (Q.size())
    {
        int city,form;
        tie(form,city)=Q.front();
        Q.pop();
        for (auto j:nei[city])
        {
            if (city<l&&j>r)
                continue;
            if (city>r&&j<l)
                continue;
            if (reach[j])
                continue;
            if (j>r&&form==1)
                continue;
            if (j<l)
                Q.push({1,j});
            else if (j>r)
                Q.push({0,j});
            else
                Q.push({form,j});
            reach[j]=1;
        }
    }
    return reach[v];
}
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 (int i=0;i<X.size();i++)
    {
        nei[X[i]].push_back(Y[i]);
        nei[Y[i]].push_back(X[i]);
    }
    vector<int>ans;
    for (int i=0;i<S.size();i++)
    {
        ans.push_back(bfs(S[i],E[i],L[i],R[i]));
        for (int j=0;j<N;j++)
            reach[j]=0;
    }
    return ans;
}

Compilation message

werewolf.cpp: In function 'bool bfs(int, int, int, int)':
werewolf.cpp:16:9: error: 'tie' was not declared in this scope
   16 |         tie(form,city)=Q.front();
      |         ^~~
werewolf.cpp:4:1: note: 'std::tie' is defined in header '<tuple>'; did you forget to '#include <tuple>'?
    3 | #include <iostream>
  +++ |+#include <tuple>
    4 | using namespace std;
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:41:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     for (int i=0;i<X.size();i++)
      |                  ~^~~~~~~~~
werewolf.cpp:47:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |     for (int i=0;i<S.size();i++)
      |                  ~^~~~~~~~~