답안 #434520

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
434520 2021-06-21T11:37:52 Z Maqsut_03 늑대인간 (IOI18_werewolf) C++14
0 / 100
551 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;
          bool f = 0;
          for (int j=0; j<l.size(); j++)
          {
                if (l[j] == 'B') f = 1;
                if (l[j] == 'O' && f) q = 2;
 
          }
          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:58:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |           for (int j=0; j<l.size(); j++)
      |                         ~^~~~~~~~~
werewolf.cpp:64:28: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   64 |           if (l.find("BO") == -1 && l.find("OB") == -1 && q < 2)
      |               ~~~~~~~~~~~~~^~~~~
werewolf.cpp:64:50: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   64 |           if (l.find("BO") == -1 && l.find("OB") == -1 && q < 2)
      |                                     ~~~~~~~~~~~~~^~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 252 ms 5580 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 252 ms 5580 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 551 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 252 ms 5580 KB Output isn't correct
2 Halted 0 ms 0 KB -