Submission #1797476


Source Code Expand

#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

int N;
vector< vector<int> > gra;
vector< bool > visit;

vector<int> dfs(int v,int dir){
	vector<int> ret(3,1);
	
	int size = gra[v].size();
	vector<int> temp(3);
	for(int i=0;i<size;++i){
		int to = gra[v][i];
		int rev = 0;
		if( to >= N ){
			rev = 1;
			to -= N;
		}
		if( visit[to] ){
			continue;
		}
		temp = dfs( to );
		visit[to] = true;

		ret[2] = max(ret[2],temp[2]);
		ret[2] = max(ret[2],temp[0]+ret[1]);
		if( rev ){
			ret[2] = max(ret[2],temp[1]+ret[0]);
		}

		ret[0] = max(ret[0],temp[0] + 1);
		if( rev ){
			ret[1] = max(ret[1],temp[1] + 1);
		}
	}

	
	{
		cout << "[" << v << "]" << endl;
		cout << ret[0] << "," << ret[1] << "," << ret[2] << endl;
	}
	
	return ret;
}
void solve(){
	return;
	cin >> N;
	gra = vector< vector<int> >(N);
	visit = vector<bool>(N,false);
	int a,b,t;
	for(int i=1;i<N;++i){
		cin >> a >> b >> t;
		--a;--b;
		if( t == 1 ){
			gra[a].push_back( b );
			//gra[b].push_back( a+N );
		}
		else if( t == 2 ){
			gra[a].push_back( b+N );
		}
	}
	vector<int> res = dfs(0);
	cout << res[2] -2 << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

Submission Info

Submission Time
Task D - Longest Path
User akarin55
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2408 Byte
Status CE

Compile Error

./Main.cpp: In function ‘std::vector<int> dfs(int, int)’:
./Main.cpp:70:18: error: too few arguments to function ‘std::vector<int> dfs(int, int)’
   temp = dfs( to );
                  ^
./Main.cpp:55:13: note: declared here
 vector<int> dfs(int v,int dir){
             ^
./Main.cpp: In function ‘void solve()’:
./Main.cpp:110:25: error: too few arguments to function ‘std::vector<int> dfs(int, int)’
  vector<int> res = dfs(0);
                         ^
./Main.cpp:55:13: note: declared here
 vector<int> dfs(int v,int dir){
             ^