답안 #341507

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
341507 2020-12-29T21:44:02 Z FlashGamezzz 늑대인간 (IOI18_werewolf) C++11
컴파일 오류
0 ms 0 KB
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <unordered_set>
#include <vector>
#include <utility>
//#include "werewolf.h"

using namespace std;

vector<int> adj[3000], szs;
bool r1[3000], r2[3000];

void dfs1(int i, int l){
	if (i >= l){
		r1[i] = true;
		for (int a : r1[i]){
			if (a >= l && !r1[a]){
				dfs1(a, l);
			}
		}
	}
}

void dfs2(int i, int r){
	if (i <= r){
		r1[i] = true;
		for (int a : r1[i]){
			if (a <= r && !r2[a]){
				dfs2(a, r);
			}
		}
	}
}

vector<int> check_validity(int N, vector<int> X, vector<int> Y, vector<int> S, vector<int> E, vector<int> L, vector<int> R) {
  int Q = S.size(); vector<int> A(Q);
  for (int i = 0; i < Q; ++i) {
	  A[i] = 0;
  }
  for (int i = 0; i < X.size(); i++){
	  adj[X[i]].push_back(Y[i]); adj[Y[i]].push_back(X[i]);
  }
  for (int i = 0; i < Q; i++) {
	  for (int j = 0; j < N; j++){
		  r1[j] = false; r2[j] = false;
	  }
	  dfs1(S[i], L[i]); dfs2(E[i], R[i]);
	  for (int j = L[i]; j <= R[i]; j++){
		  if (r1[j] && r2[j]){
			  A[j] = 1; break;
		  }
	  }
  }
  return A;
}

Compilation message

werewolf.cpp: In function 'void dfs1(int, int)':
werewolf.cpp:19:20: error: 'begin' was not declared in this scope; did you mean 'std::begin'?
   19 |   for (int a : r1[i]){
      |                    ^
      |                    std::begin
In file included from /usr/include/c++/9/string:54,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/ostream:38,
                 from /usr/include/c++/9/iostream:39,
                 from werewolf.cpp:1:
/usr/include/c++/9/bits/range_access.h:87:5: note: 'std::begin' declared here
   87 |     begin(_Tp (&__arr)[_Nm])
      |     ^~~~~
werewolf.cpp:19:20: error: 'end' was not declared in this scope; did you mean 'std::end'?
   19 |   for (int a : r1[i]){
      |                    ^
      |                    std::end
In file included from /usr/include/c++/9/string:54,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/ostream:38,
                 from /usr/include/c++/9/iostream:39,
                 from werewolf.cpp:1:
/usr/include/c++/9/bits/range_access.h:97:5: note: 'std::end' declared here
   97 |     end(_Tp (&__arr)[_Nm])
      |     ^~~
werewolf.cpp: In function 'void dfs2(int, int)':
werewolf.cpp:30:20: error: 'begin' was not declared in this scope; did you mean 'std::begin'?
   30 |   for (int a : r1[i]){
      |                    ^
      |                    std::begin
In file included from /usr/include/c++/9/string:54,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/ostream:38,
                 from /usr/include/c++/9/iostream:39,
                 from werewolf.cpp:1:
/usr/include/c++/9/bits/range_access.h:87:5: note: 'std::begin' declared here
   87 |     begin(_Tp (&__arr)[_Nm])
      |     ^~~~~
werewolf.cpp:30:20: error: 'end' was not declared in this scope; did you mean 'std::end'?
   30 |   for (int a : r1[i]){
      |                    ^
      |                    std::end
In file included from /usr/include/c++/9/string:54,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/ostream:38,
                 from /usr/include/c++/9/iostream:39,
                 from werewolf.cpp:1:
/usr/include/c++/9/bits/range_access.h:97:5: note: 'std::end' declared here
   97 |     end(_Tp (&__arr)[_Nm])
      |     ^~~
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:21: 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++){
      |                   ~~^~~~~~~~~~