답안 #794390

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
794390 2023-07-26T13:51:38 Z firewater 장난감 기차 (IOI17_train) C++14
컴파일 오류
0 ms 0 KB
#include "train.h"
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include <cassert>
#define ll long long
#define MX 20230
using namespace std;
int n,m,a[MX],c[MX],h[MX],H[MX];
struct rec
{
	int to,nx;
}e[MX],E[MX];
void addl(int x,int y)
{
	e[++tot].to=y;
	e[tot].nx=h[x];
	h[x]=tot;
	return;
}
void addll(int x,int y)
{
	E[tot].to=y;
	E[tot].nx=H[x];
	H[x]=tot;
	return;
}
void dfs1(int x)
{
	for(int i=h[x];i;i=e[i].nx){
		int y=e[i].to;
		if(p[y])continue;
		dfs1(y);
	}
	ls.push_back(i);
	return;
}
void dfs2(int x,int p)
{
	fr[x]=p;
	for(int i=H[x];i;i=E[i].nx){
		int y=E[i].to;
		if(fr[y])continue;
		dfs2(y,p);
	}
	return;
}
void dfs3(int x)
{
	cc[fr[x]]=1;
	for(int i=H[x];i;i=E[i].nx){
		int y=E[i].to;
		if(cc[fr[y]])continue;
		dfs3(y);
	}
	return;
}
std::vector<int> who_wins(std::vector<int> A, std::vector<int> C, std::vector<int> U, std::vector<int> V) {
	std::vector<int> ans(A.size());
	n=A.size();
	m=U.size();
	for(int i=1;i<=n;++i){
		a[i]=A[i-1];
		c[i]=C[i-1];
	}
	for(int i=0;i<m;++i){
		addl(U[i]+1,V[i]+1);
		addll(V[i]+1,U[i]+1);
	}
	for(int i=1;i<=n;++i)
		p[i]=0;
	for(int i=1;i<=n;++i)
		if(!p[i])
			dfs1(i);
	reverse(ls.begin(),ls.end());
	for(int i=0;i<ls.size();++i)
		if(!fr[ls[i]])
			dfs2(ls[i],++w);
	for(int i=1;i<=n;++i)
		if(c[i])
			cc[fr[i]]=1;
	for(int i=1;i<=n;++i)
		if(cc[fr[i]])
			dfs3(i);
	for(int i=1;i<=n;+=i)
		ans[i-1]=cc[fr[i]];
	return ans;
}





Compilation message

train.cpp: In function 'void addl(int, int)':
train.cpp:17:6: error: 'tot' was not declared in this scope
   17 |  e[++tot].to=y;
      |      ^~~
train.cpp: In function 'void addll(int, int)':
train.cpp:24:4: error: 'tot' was not declared in this scope
   24 |  E[tot].to=y;
      |    ^~~
train.cpp: In function 'void dfs1(int)':
train.cpp:33:6: error: 'p' was not declared in this scope
   33 |   if(p[y])continue;
      |      ^
train.cpp:36:2: error: 'ls' was not declared in this scope; did you mean 'll'?
   36 |  ls.push_back(i);
      |  ^~
      |  ll
train.cpp:36:15: error: 'i' was not declared in this scope
   36 |  ls.push_back(i);
      |               ^
train.cpp: In function 'void dfs2(int, int)':
train.cpp:41:2: error: 'fr' was not declared in this scope
   41 |  fr[x]=p;
      |  ^~
train.cpp: In function 'void dfs3(int)':
train.cpp:51:2: error: 'cc' was not declared in this scope; did you mean 'c'?
   51 |  cc[fr[x]]=1;
      |  ^~
      |  c
train.cpp:51:5: error: 'fr' was not declared in this scope
   51 |  cc[fr[x]]=1;
      |     ^~
train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:72:3: error: 'p' was not declared in this scope
   72 |   p[i]=0;
      |   ^
train.cpp:74:7: error: 'p' was not declared in this scope
   74 |   if(!p[i])
      |       ^
train.cpp:76:10: error: 'ls' was not declared in this scope; did you mean 'll'?
   76 |  reverse(ls.begin(),ls.end());
      |          ^~
      |          ll
train.cpp:78:7: error: 'fr' was not declared in this scope
   78 |   if(!fr[ls[i]])
      |       ^~
train.cpp:79:17: error: 'w' was not declared in this scope
   79 |    dfs2(ls[i],++w);
      |                 ^
train.cpp:82:4: error: 'cc' was not declared in this scope; did you mean 'c'?
   82 |    cc[fr[i]]=1;
      |    ^~
      |    c
train.cpp:82:7: error: 'fr' was not declared in this scope
   82 |    cc[fr[i]]=1;
      |       ^~
train.cpp:84:6: error: 'cc' was not declared in this scope; did you mean 'c'?
   84 |   if(cc[fr[i]])
      |      ^~
      |      c
train.cpp:84:9: error: 'fr' was not declared in this scope
   84 |   if(cc[fr[i]])
      |         ^~
train.cpp:86:19: error: expected primary-expression before '+=' token
   86 |  for(int i=1;i<=n;+=i)
      |                   ^~
train.cpp:87:12: error: 'cc' was not declared in this scope; did you mean 'c'?
   87 |   ans[i-1]=cc[fr[i]];
      |            ^~
      |            c
train.cpp:87:15: error: 'fr' was not declared in this scope
   87 |   ans[i-1]=cc[fr[i]];
      |               ^~