답안 #600839

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
600839 2022-07-21T08:12:05 Z enerelt14 늑대인간 (IOI18_werewolf) C++14
0 / 100
129 ms 19672 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){
    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 j=0;j<Q;j++){
        ans[j]=0;
        if (S[j]<L[j] || E[j]>R[j])continue;
        for (int i=L[j];i<N;i++)vis[i]=0;
        dijkstra1(S[j], L[j]);
        for (int i=L[j];i<=R[j];i++)is[i]=vis[i];
        for (int i=0;i<=R[j];i++)vis[i]=0;
        dijkstra2(E[j], R[j]);
        for (int i=L[j];i<=R[j];i++){
            if (vis[i] && is[i]){
                ans[j]=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:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for (int i=0;i<X.size();i++){
      |                  ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 129 ms 19672 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -