답안 #301663

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
301663 2020-09-18T05:49:19 Z Muhammetali 슈퍼트리 잇기 (IOI20_supertrees) C++14
컴파일 오류
0 ms 0 KB
#include "supertrees.h"
#include <bits/stdc++.h>
#define mp make_pair
#define f first
#define s second
#define sz(x) (int)(x).size()
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pf push_front
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
vi get_comp(vector<vi>& adj,vector<bool>& vis,int k)
{
	assert(vis[k]);
	vis[k]=1;
	vi comp(1,k);
	for (int i=0;i<sz(comp);i++)
	{
		assert(vis[comp[i]]);
		for (int j:adj[comp[i]])
		{
			if (!vis[j])
			{
				vis[com[i]=1;
				comp.pb(i);
			}
		}
	}
	return comp;
}
int construct(vector<vi> p)
{
	int n=sz(p);
	vector<vi> ans(n,vi(n));
	vector<vi> adjtree(n),adjcycl(n);
	for (int i=0;i<n;i++)
	{
		for (int j=0;j<n;j++)
		{
			if (p[i][j]==3)return 0;
			if (p[i][j]==1)adjtree[i].pb(j);
		}
	}
	vector<bool> vis(n);
	for (int i=0;i<n;i++)
	{
		if (!vis[i])
		{
			trees.pb(get_comp(adjtree,vis,i));
			roots.pb(trees.bk.bk);
		}
	}
	for (int i:trees)
	{
		for (int j:sz(trees[i]))
		{
			ans[i][j]=1;
			ans[j][i]=1;
		}
	}
	for (int i:roots)
	{
		for (int j:roots)
		{
			if (p[i][j]==2)adjcycl[i].pb(j);
		}
	}
	vis=vector<bool>(n);
	for (int i:roots)
	{
		if (!vis[i])
		{
			vi v=get_comp(adjcycl,vis,i);
			for (int i:v)
			{
				for (int j:v)
				{
					if (p[i][j]!=2 && i!=j)return 0;
				}
			}
			if (sz(v)>=2)return 0;
			for (int i:v)
			{
				for (int j:v)
				{
					ans[i][j]=2;
				}
			}
		}
	}
	for (int i=0;i<n;i++)
	{
		for (int j=0;j<n;j++)
		{
			ans[i][j]|=ans[j][i];
			ans[j][i]|=ans[i][j];
		}
	}
	for (int i=0;i<np;i++)ans[i][i]=0;
	build(ans);
	return 1;
}

Compilation message

supertrees.cpp: In function 'vi get_comp(std::vector<std::vector<int> >&, std::vector<bool>&, int)':
supertrees.cpp:33:9: error: 'com' was not declared in this scope; did you mean 'comp'?
   33 |     vis[com[i]=1;
      |         ^~~
      |         comp
supertrees.cpp:33:17: error: expected ']' before ';' token
   33 |     vis[com[i]=1;
      |                 ^
      |                 ]
supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:58:4: error: 'trees' was not declared in this scope
   58 |    trees.pb(get_comp(adjtree,vis,i));
      |    ^~~~~
supertrees.cpp:59:4: error: 'roots' was not declared in this scope
   59 |    roots.pb(trees.bk.bk);
      |    ^~~~~
supertrees.cpp:62:13: error: 'trees' was not declared in this scope
   62 |  for (int i:trees)
      |             ^~~~~
supertrees.cpp:70:13: error: 'roots' was not declared in this scope
   70 |  for (int i:roots)
      |             ^~~~~
supertrees.cpp:78:13: error: 'roots' was not declared in this scope
   78 |  for (int i:roots)
      |             ^~~~~
supertrees.cpp:108:17: error: 'np' was not declared in this scope; did you mean 'n'?
  108 |  for (int i=0;i<np;i++)ans[i][i]=0;
      |                 ^~
      |                 n