Submission #349536

# Submission time Handle Problem Language Result Execution time Memory
349536 2021-01-17T18:56:08 Z NachoLibre Dreaming (IOI13_dreaming) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#ifndef wambule
#include "dreaming.h"
#endif

const int N = 100005;
int dp[N][4];
vector<pair<int, int> > v[N];
vector<int> ve;
bool bo[N];

pair<int, int> ovod(int dg, int op, int mn) {
	bo[dg] = 1;
	pair<int, int> dr = {0, dg};
	for(int i = 0; i < v[dg].size(); ++i) {
		if(v[dg][i].first != op) {
			pair<int, int> p = ovod(v[dg][i].first, dg, mn + v[dg][i].second);
			if(p.first > dr.first) dr = p;
		}
	}
	return dr;
}

void ovog(int dg, int op, int mn, int sv) {
	ve.push_back(mn);
	if(dg == sv) {
		ve[0] = -1;
		return;
	}
	for(int i = 0; i < v[dg].size(); ++i) {
		if(v[dg][i].first != op) {
			ovog(v[dg][i].first, dg, mn + v[dg][i].second, sv);
			if(ve[0] == -1) return;
		}
	}
	ve.pop_back();
}

void ovoq(int dg, int op) {
	dp[dg][0] = dg;
	dp[dg][1] = dp[dg][2] = dp[dg][3] = 0;
	for(int i = 0; i < v[dg].size(); ++i) {
		if(v[dg][i].first != op) {
			ovoq(v[dg][i].first, dg);
			int x = dp[v[dg][i].first][1];
			if(x > dp[dg][1]) {
				dp[dg][2] = dp[dg][1];
				dp[dg][1] = x;
				dp[dg][0] = dp[v[dg][i].first][0];
			} else if(x > dp[dg][2]) {
				dp[dg][2] = x;
			}
		}
	}
}

int ovox(int dg, int op) {
	int dr = 0;
	for(int i = 0; i < v[dg].size(); ++i) {
		if(v[dg][i].first != op) {
			int x = (v[dg][i].first == dp[dg][0] ? dp[dg][2] : dp[dg][1]);
			dp[v[dg][i].first][3] = max(dp[dg][3], x) + v[dg][i].second;
			dr = max(dr, ovox(v[dg][i].first, dg));
		}
	}
	return max(dr, max(dp[dg][1], dp[dg][3]));
}

int tavelTime(int n, int m, int l, vector<int> a, vector<int> b, vector<int> c) {
	for(int i = 0; i < n; ++i) {
		v[i].clear();
		bo[i] = 0;
	}
	for(int i = 0; i < m; ++i) {
		v[a[i]].push_back({b[i], c[i]});
		v[b[i]].push_back({a[i], c[i]});
	}
	vector<int> wv;
	for(int i = 0; i < n; ++i) {
		if(!bo[i]) {
			int x = 0;
			pair<int, int> p = ovod(x = ovod(0, -1, 0).second, -1, 0);
			ve.clear();
			ovog(x, -1, 0, p.second);
			ve[0] = 0;
			int a = p.first;
			for(int i = 1; i < ve.size(); ++i) {
				a = min(a, max(ve[i], p.first - ve[i]));
			}
			ovoq(0, -1);
			int b = ovox(0, -1);
			wv.push_back((assert(a == b), a = b));
		}
	}
	return 0;
}

#ifdef wambule
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	return 0;
}
#endif

Compilation message

dreaming.cpp: In function 'std::pair<int, int> ovod(int, int, int)':
dreaming.cpp:16:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |  for(int i = 0; i < v[dg].size(); ++i) {
      |                 ~~^~~~~~~~~~~~~~
dreaming.cpp: In function 'void ovog(int, int, int, int)':
dreaming.cpp:31:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |  for(int i = 0; i < v[dg].size(); ++i) {
      |                 ~~^~~~~~~~~~~~~~
dreaming.cpp: In function 'void ovoq(int, int)':
dreaming.cpp:43:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |  for(int i = 0; i < v[dg].size(); ++i) {
      |                 ~~^~~~~~~~~~~~~~
dreaming.cpp: In function 'int ovox(int, int)':
dreaming.cpp:60:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |  for(int i = 0; i < v[dg].size(); ++i) {
      |                 ~~^~~~~~~~~~~~~~
dreaming.cpp: In function 'int tavelTime(int, int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
dreaming.cpp:88:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   88 |    for(int i = 1; i < ve.size(); ++i) {
      |                   ~~^~~~~~~~~~~
/tmp/ccSgwS0i.o: In function `main':
grader.c:(.text.startup+0xc9): undefined reference to `travelTime'
collect2: error: ld returned 1 exit status