Submission #741078

# Submission time Handle Problem Language Result Execution time Memory
741078 2023-05-13T14:14:02 Z almothana05 Werewolf (IOI18_werewolf) C++14
0 / 100
4000 ms 33692 KB
#include "werewolf.h"
#include<bits/stdc++.h>
using namespace std;
int vis[2][300000];
vector<int>kinder[300000] , erg;
priority_queue<pair<int ,int> >q;
bool bfs(int x , int en , int l , int r){
  if(x >= l){
    q.push({0 , x});
  }
  if(x <= r){
    q.push({1 , x});
  }
  while(q.size()){
    int jet = q.top().second , cmp = q.top().first;
    q.pop();
    for(int i = 0 ; i < kinder[jet].size() ; i++){
      int kind = kinder[jet][i];
      if(cmp == 1){
        if(kind <= r && vis[1][kind] == 0){
          vis[1][kind] = 1;
          q.push({1 , kind});
        }
      }
      else{
        if(kind <= r && vis[1][kind] == 0 && (kind >= l || jet <= r)){
          vis[1][kind] = 1;
          q.push({1 , kind});
        }
        if(kind >= l && vis[0][kind] == 0){
          vis[0][kind] = 1;
          q.push({0 , kind});
        }
      }
      
    }
  }
  return vis[0][en] == 1 || vis[1][en] == 1;
}
vector<int> check_validity(int menge, vector<int> x, vector<int> y,
                                vector<int> s, vector<int> e,
                                vector<int> l, vector<int> r) {
  if(x.size() == menge - 1){

  } 
  for(int i = 0 ; i < menge ; i++){
    kinder[x[i]].push_back(y[i]);
    kinder[y[i]].push_back(x[i]);
  }
  for(int i = 0 ; i < s.size() ; i++){
    for(int i = 0 ; i < menge ; i++){
      vis[0][i] = 0;
      vis[1][i] = 0;
    }
    int x = bfs(s[i] , e[i] , l[i] , r[i]);
    erg.push_back(x);
  }                
  return erg;
}

Compilation message

werewolf.cpp: In function 'bool bfs(int, int, int, int)':
werewolf.cpp:17:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for(int i = 0 ; i < kinder[jet].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:43:15: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   43 |   if(x.size() == menge - 1){
      |      ~~~~~~~~~^~~~~~~~~~~~
werewolf.cpp:50:21: 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 < s.size() ; i++){
      |                   ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 7380 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 7380 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4043 ms 33692 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 7380 KB Output isn't correct
2 Halted 0 ms 0 KB -