Submission #806763

# Submission time Handle Problem Language Result Execution time Memory
806763 2023-08-04T09:39:45 Z Benmath Werewolf (IOI18_werewolf) C++14
15 / 100
4000 ms 25720 KB
#include <cstdio>
#include <cstdlib>
#include <vector>
#include<bits/stdc++.h>
#include "werewolf.h"

namespace {

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

}  // namespace
using namespace std;

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) {
  int q = S.size();
  std::vector<int> A(q);
  vector<int>adjl[n+1];
  int m=X.size();
  for(int i=0;i<m;i++){
  adjl[X[i]].push_back(Y[i]);
  adjl[Y[i]].push_back(X[i]);
  }
  for (int i = 0; i < q; ++i) {
    A[i] = 0;
    int x=S[i];
    int y=E[i];
    int l=L[i];
    int r=R[i];
    
    int wolf[n+1];
    int human[n+1];
    for(int j=0;j<n;j++){
  wolf[j]=0;
  human[j]=0;
    
    
  }
  queue<int>q;
  q.push(x);
  human[x]++;
  while(!q.empty()){
  int a=q.front();
  q.pop();
  for(int j=0;j<adjl[a].size();j++){
  if(human[adjl[a][j]]==0 and adjl[a][j]>=l){
  human[adjl[a][j]]++;
  q.push(adjl[a][j]);
  }
  }
  }
  q.push(y);
  wolf[y]++;
   while(!q.empty()){
  int a=q.front();
  q.pop();
  for(int j=0;j<adjl[a].size();j++){
  if(wolf[adjl[a][j]]==0 and adjl[a][j]<=r){
  wolf[adjl[a][j]]++;
  q.push(adjl[a][j]);
  }
  }
  }
  for(int j=0;j<n;j++){
  if(human[j]>0 and wolf[j]>0){
  A[i]++;
  }
  }
  A[i]=min(A[i],1);
  }
  return A;
}

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:53:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |   for(int j=0;j<adjl[a].size();j++){
      |               ~^~~~~~~~~~~~~~~
werewolf.cpp:65:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |   for(int j=0;j<adjl[a].size();j++){
      |               ~^~~~~~~~~~~~~~~
werewolf.cpp: At global scope:
werewolf.cpp:9:5: warning: 'int {anonymous}::read_int()' defined but not used [-Wunused-function]
    9 | int read_int() {
      |     ^~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 304 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 304 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 212 ms 732 KB Output is correct
11 Correct 123 ms 724 KB Output is correct
12 Correct 15 ms 724 KB Output is correct
13 Correct 230 ms 736 KB Output is correct
14 Correct 148 ms 728 KB Output is correct
15 Correct 200 ms 852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 4037 ms 25720 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 304 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 212 ms 732 KB Output is correct
11 Correct 123 ms 724 KB Output is correct
12 Correct 15 ms 724 KB Output is correct
13 Correct 230 ms 736 KB Output is correct
14 Correct 148 ms 728 KB Output is correct
15 Correct 200 ms 852 KB Output is correct
16 Execution timed out 4037 ms 25720 KB Time limit exceeded
17 Halted 0 ms 0 KB -