Submission #434476

# Submission time Handle Problem Language Result Execution time Memory
434476 2021-06-21T10:57:12 Z Maqsut_03 Werewolf (IOI18_werewolf) C++14
0 / 100
644 ms 524292 KB
#include "werewolf.h"
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 222222;

vector<string> vec;
vector<ll> v[N];
char a[N];
bool used[N];
bool ans;

void dfs(int i, int j, int k, string s)
{
    used[i] = 1;
    if (i == k)
    {
        vec.push_back(s);
        used[i] = 0;
        return ;
    }
    for (auto l:v[i])
    {
        if (!used[l])
        {
            dfs(l, i, k, s + a[l]);
        }
    }
    used[i] = 0;
}

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, 0);

  for (int i=0; i<N; i++)
  {
      v[X[i]].push_back(Y[i]);
      v[Y[i]].push_back(X[i]);
  }
  for (int i=0; i<q; i++)
  {
      ans = false;
      vec.clear();
      for (int j=0; j<L[i]; j++) a[j] = 'B';
      for (int j=L[i]; j<=R[i]; j++) a[j] = 'T';
      for (int j=R[i]+1; j<N; j++) a[j] = 'O';
      string WW = "";
      WW += a[S[i]];
      dfs(S[i], -1, E[i], WW);

      for (string l:vec)
      {
          int q = 0;
          for (int j=1; j<l.size(); j++)
                if (l[j-1] == 'O' && l[j] == 'T') q++;
          if (l.find("BO") == -1 && l.find("OB") == -1 && q < 2)
          {

              ans = 1;
              break;
          }

      }

      if (ans) A[i] = 1;
      else A[i] = 0;
  }
  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:57:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |           for (int j=1; j<l.size(); j++)
      |                         ~^~~~~~~~~
werewolf.cpp:59:28: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   59 |           if (l.find("BO") == -1 && l.find("OB") == -1 && q < 2)
      |               ~~~~~~~~~~~~~^~~~~
werewolf.cpp:59:50: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   59 |           if (l.find("BO") == -1 && l.find("OB") == -1 && q < 2)
      |                                     ~~~~~~~~~~~~~^~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 254 ms 5580 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 254 ms 5580 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 644 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 254 ms 5580 KB Output isn't correct
2 Halted 0 ms 0 KB -