답안 #341517

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
341517 2020-12-29T22:11:32 Z FlashGamezzz 늑대인간 (IOI18_werewolf) C++11
15 / 100
286 ms 21356 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];
bool r1[3000], r2[3000];
int cr, cl;

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

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

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;
	  }
	  cr = R[i]; cl = L[i];
	  dfs1(S[i]); dfs2(E[i]);
	  for (int j = L[i]; j <= R[i]; j++){
		  if (r1[j] && r2[j]){
			  A[i] = 1; break;
		  }
	  }
  }
  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:44:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |   for (int i = 0; i < X.size(); i++){
      |                   ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 259 ms 876 KB Output is correct
11 Correct 163 ms 800 KB Output is correct
12 Correct 35 ms 876 KB Output is correct
13 Correct 286 ms 876 KB Output is correct
14 Correct 195 ms 832 KB Output is correct
15 Correct 250 ms 1004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 176 ms 21356 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 259 ms 876 KB Output is correct
11 Correct 163 ms 800 KB Output is correct
12 Correct 35 ms 876 KB Output is correct
13 Correct 286 ms 876 KB Output is correct
14 Correct 195 ms 832 KB Output is correct
15 Correct 250 ms 1004 KB Output is correct
16 Runtime error 176 ms 21356 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Halted 0 ms 0 KB -