제출 #786470

#제출 시각아이디문제언어결과실행 시간메모리
786470khshg수천개의 섬 (IOI22_islands)C++17
컴파일 에러
0 ms0 KiB
#include "islands.h"
#include<bits/stdc++.h>
using namespace std;

vector<vector<pair<int, int>>> adj;
vector<int> c;
bool dfs(int s) {//, vector<int>& nds) {
	c[s] = 1;
	for(auto& u : adj[s]) {
		if(c[u.first] == 0) {if(dfs(u.first)) return 1;}
		else if(c[u.first] == 1) {
			return 1;
		}
	}
	nds[s] = 2;
	return false;
}

variant<bool, vector<int>> find_journey(int N, int M, vector<int> U, vector<int> V) {
//vector<int> find_journey(int N, int M, vector<int> U, vector<int> V) {
	c.resize(N);
	adj.resize(N);
	for(int i = 0; i < M; i += 2) {
		adj[U[i]].emplace_back(V[i], i);
	}
	return dfs(0);
/*	int cur = 0, prev = -1;
	vector<int> way, ans;
	while(1) {
		int cs = out[cur] - (prev != -1);
		if(cs == 0) return false;
		if(cs == 1) {
			for(auto& u : adj[cur]) if(u.first != prev) {
				way.push_back(u.second[0]);
				prev = cur;
				cur = u.first;
				break;
			}
			continue;
		}
		break;
	}
	//return true;
	ans = way;
	vector<pair<int, int>> z;
	for(auto& u : adj[cur]) if(u.first != prev) {
		for(auto& v : u.second) {
			z.push_back(v);
			if((int)z.size() == 2) break;
		}
		if((int)z.size() == 2) break;
	}
	ans.push_back(z[0]);
	ans.push_back(z[0] / 2 * 4 + 1 - z[0]);
	ans.push_back(z[1]);
	ans.push_back(z[1] / 2 * 4 + 1 - z[1]);
	ans.push_back(z[0] / 2 * 4 + 1 - z[0]);
	ans.push_back(z[0]);
	ans.push_back(z[1] / 2 * 4 + 1 - z[1]);
	ans.push_back(z[1]);
	reverse(begin(way), end(way));
	for(auto& u : way) ans.push_back(u);
	return ans;*/
}
/*
int main() {
  int N, M;
  assert(2 == scanf("%d %d", &N, &M));

  std::vector<int> U(M), V(M);
  for (int i = 0; i < M; ++i) {
    assert(2 == scanf("%d %d", &U[i], &V[i]));
  }
  vector<int> result = find_journey(N, M, U, V);
  for(auto& u : result) {
	  cout << u << '\n';
  }
}*/

컴파일 시 표준 에러 (stderr) 메시지

islands.cpp: In function 'bool dfs(int)':
islands.cpp:15:2: error: 'nds' was not declared in this scope
   15 |  nds[s] = 2;
      |  ^~~