Submission #1066926

# Submission time Handle Problem Language Result Execution time Memory
1066926 2024-08-20T08:51:31 Z Muhammad_Aneeq Werewolf (IOI18_werewolf) C++17
7 / 100
4000 ms 30412 KB
#include <vector>
#include <queue>
#include <iostream>
#include <algorithm>
#include "bits/stdc++.h"
using namespace std;
int const N=2e5+10;
vector<int>nei[N]={};
bool reach[N]={};
bool bfs(int u,int v,int l,int r)
{
    queue<pair<int,int>>Q;
    Q.push({0,u});
    reach[u]=1;
    while (Q.size())
    {
        int city,form;
        tie(form,city)=Q.front();
        Q.pop();
        for (auto j:nei[city])
        {
            if (city<l&&j>r)
                continue;
            if (city>r&&j<l)
                continue;
            if (reach[j])
                continue;
            if (j>r&&form==1)
                continue;
            if (j<l)
                Q.push({1,j});
            else if (j>r&&form==0)
                Q.push({0,j});
            else
                Q.push({form,j});
            reach[j]=1;
        }
    }
    return reach[v];
}
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++)
    {
        nei[X[i]].push_back(Y[i]);
        nei[Y[i]].push_back(X[i]);
    }
    vector<int>ans;
    for (int i=0;i<S.size();i++)
    {
        ans.push_back(bfs(S[i],E[i],L[i],R[i]));
        for (int j=0;j<N;j++)
            reach[j]=0;
    }
    return ans;
}

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:43:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |     for (int i=0;i<X.size();i++)
      |                  ~^~~~~~~~~
werewolf.cpp:49:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |     for (int i=0;i<S.size();i++)
      |                  ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4956 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 3 ms 4956 KB Output is correct
4 Correct 2 ms 4956 KB Output is correct
5 Correct 2 ms 4956 KB Output is correct
6 Correct 2 ms 5140 KB Output is correct
7 Correct 3 ms 4956 KB Output is correct
8 Correct 2 ms 4956 KB Output is correct
9 Correct 2 ms 4956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4956 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 3 ms 4956 KB Output is correct
4 Correct 2 ms 4956 KB Output is correct
5 Correct 2 ms 4956 KB Output is correct
6 Correct 2 ms 5140 KB Output is correct
7 Correct 3 ms 4956 KB Output is correct
8 Correct 2 ms 4956 KB Output is correct
9 Correct 2 ms 4956 KB Output is correct
10 Incorrect 204 ms 5492 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4062 ms 30412 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4956 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 3 ms 4956 KB Output is correct
4 Correct 2 ms 4956 KB Output is correct
5 Correct 2 ms 4956 KB Output is correct
6 Correct 2 ms 5140 KB Output is correct
7 Correct 3 ms 4956 KB Output is correct
8 Correct 2 ms 4956 KB Output is correct
9 Correct 2 ms 4956 KB Output is correct
10 Incorrect 204 ms 5492 KB Output isn't correct
11 Halted 0 ms 0 KB -