답안 #600800

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
600800 2022-07-21T07:54:30 Z enerelt14 늑대인간 (IOI18_werewolf) C++14
컴파일 오류
0 ms 0 KB
#include "werewolf.h"
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
bool vis[3005], is[3005];
vector<int>adj[3005];
void dijkstra1(int s, int l){
    queue<int>pq;
    pq.push(s);
    while(!pq.empty()){
        int u=pq.front();
        pq.pop();
        vis[u]=1;
        for (int i=0;i<adj[u].size();i++){
            if (adj[u][i]<l || vis[adj[u][i]])continue;
            pq.push(adj[u][i]);
        }
        while(!pq.empty() && vis[pq.front()])pq.pop();
    }
}
void dijkstra2(int s, int r){
    queue<int>pq;
    pq.push(s);
    while(!pq.empty()){
        int u=pq.front();
        pq.pop();
        vis[u]=1;
        for (int i=0;i<adj[u].size();i++){
            if (adj[u][i]>r || vis[adj[u][i]])continue;
            pq.push(adj[u][i]);
        }
        while(!pq.empty() && vis[pq.front()])pq.pop();
    }
}
vector<int>check_validity(int N,vector<int>X,vector<int>Y,vector<int>S,vector<int>E,vector<int>L,vector<int>R){
    n=N:
    for (int i=0;i<X.size();i++){
        adj[X[i]].pb(Y[i]);
        adj[Y[i]].pb(X[i]);
    }
    int Q=S.size();
    vector<int>ans;
    for (int i=0;i<Q;i++){
        ans[i]=0;
        if (S[i]<L[i] || E[i]>R[i])continue;
        for (int i=L[i];i<n;i++)vis[i]=0;
        dijkstra1(S[i], L[i]);
        for (int i=L[i];i<=R[i];i++)is[i]=vis[i];
        for (int i=0;i<=R[i];i++)vis[i]=0;
        dijkstra2(E[i], R[i]);
        for (int i=L[i];i<=R[i];i++){
            if (vis[i] && is[i]){
                ans[i]=1;
                break;
            }
        }
    }
    return ans;
}

Compilation message

werewolf.cpp: In function 'void dijkstra1(int, int)':
werewolf.cpp:14:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |         for (int i=0;i<adj[u].size();i++){
      |                      ~^~~~~~~~~~~~~~
werewolf.cpp: In function 'void dijkstra2(int, int)':
werewolf.cpp:28:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |         for (int i=0;i<adj[u].size();i++){
      |                      ~^~~~~~~~~~~~~~
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:36:5: error: 'n' was not declared in this scope
   36 |     n=N:
      |     ^
werewolf.cpp:37:18: error: 'i' was not declared in this scope
   37 |     for (int i=0;i<X.size();i++){
      |                  ^