답안 #1013594

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1013594 2024-07-03T17:11:28 Z MarwenElarbi 늑대인간 (IOI18_werewolf) C++17
0 / 100
99 ms 27476 KB
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define ll long long
#define pb push_back
#define ii pair<int,int>
const int nax=3e3+5;
vector<int> adj[nax];
vector<int> mn(nax);
vector<int> mx(nax);
bool vis[nax];
int n;
void min_djikastra(int x){
    priority_queue<int,vector<int>,greater<int>> pq;
    pq.push(x);
    mn[x]=x;
    vis[x]=true;
    while(!pq.empty()){
        int node=pq.top();
        pq.pop();
        for(auto u:adj[node]){
            if(vis[u]) continue;
            vis[u]=true;
            mn[u]=min(u,mn[node]);
            pq.push(u);
        }
    }
}
void max_djikastra(int x){
    priority_queue<int> pq;
    pq.push(x);
    mx[x]=x;
    vis[x]=true;
    while(!pq.empty()){
        int node=pq.top();
        pq.pop();
        for(auto u:adj[node]){
            if(vis[u]) continue;
            vis[u]=true;
            mx[u]=max(u,mx[node]);
            pq.push(u);
        }
    }
}
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) {
    n=N;
    for (int i = 0; i < X.size(); ++i)
    {
        adj[X[i]].pb(Y[i]);
        adj[Y[i]].pb(X[i]);
    }
    vector<int> ans;
    int Q=R.size();
    for (int i = 0; i < Q; ++i)
    {
        for (int j = 0; j < N; ++j)
        {
            mn[j]=1e9;
            mx[j]=-1e9;
        }
        memset(vis,0,sizeof vis);
        min_djikastra(S[i]);
        memset(vis,0,sizeof vis);
        max_djikastra(E[i]);
        pair<int,int> cur={L[i],R[i]};
        bool test=false;
        for (int j = 0; j < N; ++j)
        {
            cout <<cur.fi<<" "<<cur.se<<" "<<mn[j]<<" "<<mx[j]<<endl;
            if(cur.fi<=mn[j]&&mx[j]<=cur.se){
                test=true;
            }
            if(test) break;
        }//cout <<endl;
        ans.pb((test==true ? 1 : 0));
    }
    return ans;
}

/*namespace {

int read_int() {
  int x;
  if (scanf("%d", &x) != 1) {
    fprintf(stderr, "Error while reading input\n");
    exit(1);
  }
  return x;
}

}  // namespace

int main() {
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
  int N = read_int();
  int M = read_int();
  int Q = read_int();
  std::vector<int> X(M), Y(M), S(Q), E(Q), L(Q), R(Q);
  for (int j = 0; j < M; ++j) {
    X[j] = read_int();
    Y[j] = read_int();
  }
  for (int i = 0; i < Q; ++i) {
    S[i] = read_int();
    E[i] = read_int();
    L[i] = read_int();
    R[i] = read_int();
  }

  std::vector<int> A = check_validity(N, X, Y, S, E, L, R);
  for (size_t i = 0; i < A.size(); ++i) {
    printf("%d\n", A[i]);
  }
  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:50:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |     for (int i = 0; i < X.size(); ++i)
      |                     ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 99 ms 27476 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -