Submission #546557

# Submission time Handle Problem Language Result Execution time Memory
546557 2022-04-07T19:42:54 Z fabijan_cikac Dreaming (IOI13_dreaming) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define pp pair<int, int>

const int N = 1e5 + 100;

int n, m, l;
vector<pp> v[N];
pp maxl[N];
int par[N]; int bio[N] = { 0 };
map<int, map<int, int> > cest;

void parent(int x){
	if (x == par[x]) return x;
	return par[x] = parent(par[x]);
}

void mergaj_1(int x, int y, int val){
	int px = parent(x); int py = parent(y);
	par[py] = px; return;
}


void find_centre(int x){
	int lx; deque<pp> q; bio[x] = 1; 
	vector<int> cl; q.push_back({x, 0}); cl.push_back(x);
	while (!q.empty()){
		int y = q.front().F; q.pop_front(); lx = y;
		for (int i = 0; i < v[y].size(); ++i){
			int z = v[y][i];
			if (!bio[z]){
				cl.push_back(z); q.push_back({z, 0}); bio[z] = 1;
			}
		}
	}
	for (int i = 0; i < cl.size(); ++i) bio[cl[i]] = 0;
	q.push_back(lx); bio[lx] = 1; int ly = lx; int dist = 0;
	map<int, int> pokaz;
	while (!q.empty()){
		int y = q.front().F; int val = q.front().S; q.pop_front(); ly = y; dist = max(dist, val);
		for (int i = 0; i < v[y].size(); ++i){
			int z = v[y][i];
			if (!bio[z]){
				cl.push_back(z); q.push_back({z, val + 1}); bio[z] = 1; pokaz[z] = y;
			}
		}
	}
	int sum_path = 0; vector<int> path; int sadpos = ly;
	while (sadpos != lx){
		path.push_back(sadpos); sadpos = pokaz[sadpos];
	}
	for (int i = 0; i < path.size() - 1; ++i)
		sumpath += 
}

int main(){
	ios_base:sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n >> m >> l;
	for (int i = 0; i < n; ++i){
		par[i] = i; maxl[i] = {i, 0};
	}	
	for (int i = 0; i < m; i++){
		cin >> v[i].F >> v[i].S.F >> v[i].S.S; --v[i].F; --v[i].S; mergaj(v[i].F, v[i].S);
		cest[v[i].F][v[i].S] = v[i].S.S; cest[v[i].S][v[i].F] = v[i].S.S; 
	}
	for (int i = 0; i < n; ++i)
		if (!bio[i]) find_centre(i);
	for (int i = 0; i < n; ++i){
		if (parent(i) != )
	}
	
	return 0;
}

Compilation message

dreaming.cpp: In function 'void parent(int)':
dreaming.cpp:18:26: error: return-statement with a value, in function returning 'void' [-fpermissive]
   18 |  if (x == par[x]) return x;
      |                          ^
dreaming.cpp:19:24: error: void value not ignored as it ought to be
   19 |  return par[x] = parent(par[x]);
      |                  ~~~~~~^~~~~~~~
dreaming.cpp: In function 'void mergaj_1(int, int, int)':
dreaming.cpp:23:17: error: void value not ignored as it ought to be
   23 |  int px = parent(x); int py = parent(y);
      |           ~~~~~~^~~
dreaming.cpp:23:37: error: void value not ignored as it ought to be
   23 |  int px = parent(x); int py = parent(y);
      |                               ~~~~~~^~~
dreaming.cpp: In function 'void find_centre(int)':
dreaming.cpp:33:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |   for (int i = 0; i < v[y].size(); ++i){
      |                   ~~^~~~~~~~~~~~~
dreaming.cpp:34:18: error: cannot convert '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} to 'int' in initialization
   34 |    int z = v[y][i];
      |                  ^
dreaming.cpp:40:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |  for (int i = 0; i < cl.size(); ++i) bio[cl[i]] = 0;
      |                  ~~^~~~~~~~~~~
dreaming.cpp:41:16: error: no matching function for call to 'std::deque<std::pair<int, int> >::push_back(int&)'
   41 |  q.push_back(lx); bio[lx] = 1; int ly = lx; int dist = 0;
      |                ^
In file included from /usr/include/c++/10/deque:67,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:68,
                 from dreaming.cpp:1:
/usr/include/c++/10/bits/stl_deque.h:1493:7: note: candidate: 'void std::deque<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::deque<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1493 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_deque.h:1493:35: note:   no known conversion for argument 1 from 'int' to 'const value_type&' {aka 'const std::pair<int, int>&'}
 1493 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_deque.h:1508:7: note: candidate: 'void std::deque<_Tp, _Alloc>::push_back(std::deque<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::deque<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1508 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_deque.h:1508:30: note:   no known conversion for argument 1 from 'int' to 'std::deque<std::pair<int, int> >::value_type&&' {aka 'std::pair<int, int>&&'}
 1508 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
dreaming.cpp:45:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |   for (int i = 0; i < v[y].size(); ++i){
      |                   ~~^~~~~~~~~~~~~
dreaming.cpp:46:18: error: cannot convert '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} to 'int' in initialization
   46 |    int z = v[y][i];
      |                  ^
dreaming.cpp:56:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |  for (int i = 0; i < path.size() - 1; ++i)
      |                  ~~^~~~~~~~~~~~~~~~~
dreaming.cpp:57:3: error: 'sumpath' was not declared in this scope; did you mean 'sum_path'?
   57 |   sumpath +=
      |   ^~~~~~~
      |   sum_path
dreaming.cpp:58:1: error: expected primary-expression before '}' token
   58 | }
      | ^
dreaming.cpp:52:6: warning: unused variable 'sum_path' [-Wunused-variable]
   52 |  int sum_path = 0; vector<int> path; int sadpos = ly;
      |      ^~~~~~~~
dreaming.cpp: In function 'int main()':
dreaming.cpp:61:11: error: 'sync_with_stdio' was not declared in this scope
   61 |  ios_base:sync_with_stdio(false);
      |           ^~~~~~~~~~~~~~~
dreaming.cpp:5:11: error: 'class std::vector<std::pair<int, int> >' has no member named 'first'
    5 | #define F first
      |           ^~~~~
dreaming.cpp:69:15: note: in expansion of macro 'F'
   69 |   cin >> v[i].F >> v[i].S.F >> v[i].S.S; --v[i].F; --v[i].S; mergaj(v[i].F, v[i].S);
      |               ^
dreaming.cpp:6:11: error: 'class std::vector<std::pair<int, int> >' has no member named 'second'
    6 | #define S second
      |           ^~~~~~
dreaming.cpp:69:25: note: in expansion of macro 'S'
   69 |   cin >> v[i].F >> v[i].S.F >> v[i].S.S; --v[i].F; --v[i].S; mergaj(v[i].F, v[i].S);
      |                         ^
dreaming.cpp:6:11: error: 'class std::vector<std::pair<int, int> >' has no member named 'second'
    6 | #define S second
      |           ^~~~~~
dreaming.cpp:69:37: note: in expansion of macro 'S'
   69 |   cin >> v[i].F >> v[i].S.F >> v[i].S.S; --v[i].F; --v[i].S; mergaj(v[i].F, v[i].S);
      |                                     ^
dreaming.cpp:5:11: error: 'class std::vector<std::pair<int, int> >' has no member named 'first'
    5 | #define F first
      |           ^~~~~
dreaming.cpp:69:49: note: in expansion of macro 'F'
   69 |   cin >> v[i].F >> v[i].S.F >> v[i].S.S; --v[i].F; --v[i].S; mergaj(v[i].F, v[i].S);
      |                                                 ^
dreaming.cpp:6:11: error: 'class std::vector<std::pair<int, int> >' has no member named 'second'
    6 | #define S second
      |           ^~~~~~
dreaming.cpp:69:59: note: in expansion of macro 'S'
   69 |   cin >> v[i].F >> v[i].S.F >> v[i].S.S; --v[i].F; --v[i].S; mergaj(v[i].F, v[i].S);
      |                                                           ^
dreaming.cpp:5:11: error: 'class std::vector<std::pair<int, int> >' has no member named 'first'
    5 | #define F first
      |           ^~~~~
dreaming.cpp:69:74: note: in expansion of macro 'F'
   69 |   cin >> v[i].F >> v[i].S.F >> v[i].S.S; --v[i].F; --v[i].S; mergaj(v[i].F, v[i].S);
      |                                                                          ^
dreaming.cpp:6:11: error: 'class std::vector<std::pair<int, int> >' has no member named 'second'
    6 | #define S second
      |           ^~~~~~
dreaming.cpp:69:82: note: in expansion of macro 'S'
   69 |   cin >> v[i].F >> v[i].S.F >> v[i].S.S; --v[i].F; --v[i].S; mergaj(v[i].F, v[i].S);
      |                                                                                  ^
dreaming.cpp:69:62: error: 'mergaj' was not declared in this scope; did you mean 'mergaj_1'?
   69 |   cin >> v[i].F >> v[i].S.F >> v[i].S.S; --v[i].F; --v[i].S; mergaj(v[i].F, v[i].S);
      |                                                              ^~~~~~
      |                                                              mergaj_1
dreaming.cpp:5:11: error: 'class std::vector<std::pair<int, int> >' has no member named 'first'
    5 | #define F first
      |           ^~~~~
dreaming.cpp:70:13: note: in expansion of macro 'F'
   70 |   cest[v[i].F][v[i].S] = v[i].S.S; cest[v[i].S][v[i].F] = v[i].S.S;
      |             ^
dreaming.cpp:6:11: error: 'class std::vector<std::pair<int, int> >' has no member named 'second'
    6 | #define S second
      |           ^~~~~~
dreaming.cpp:70:21: note: in expansion of macro 'S'
   70 |   cest[v[i].F][v[i].S] = v[i].S.S; cest[v[i].S][v[i].F] = v[i].S.S;
      |                     ^
dreaming.cpp:6:11: error: 'class std::vector<std::pair<int, int> >' has no member named 'second'
    6 | #define S second
      |           ^~~~~~
dreaming.cpp:70:31: note: in expansion of macro 'S'
   70 |   cest[v[i].F][v[i].S] = v[i].S.S; cest[v[i].S][v[i].F] = v[i].S.S;
      |                               ^
dreaming.cpp:6:11: error: 'class std::vector<std::pair<int, int> >' has no member named 'second'
    6 | #define S second
      |           ^~~~~~
dreaming.cpp:70:46: note: in expansion of macro 'S'
   70 |   cest[v[i].F][v[i].S] = v[i].S.S; cest[v[i].S][v[i].F] = v[i].S.S;
      |                                              ^
dreaming.cpp:5:11: error: 'class std::vector<std::pair<int, int> >' has no member named 'first'
    5 | #define F first
      |           ^~~~~
dreaming.cpp:70:54: note: in expansion of macro 'F'
   70 |   cest[v[i].F][v[i].S] = v[i].S.S; cest[v[i].S][v[i].F] = v[i].S.S;
      |                                                      ^
dreaming.cpp:6:11: error: 'class std::vector<std::pair<int, int> >' has no member named 'second'
    6 | #define S second
      |           ^~~~~~
dreaming.cpp:70:64: note: in expansion of macro 'S'
   70 |   cest[v[i].F][v[i].S] = v[i].S.S; cest[v[i].S][v[i].F] = v[i].S.S;
      |                                                                ^
dreaming.cpp:75:20: error: expected primary-expression before ')' token
   75 |   if (parent(i) != )
      |                    ^
dreaming.cpp:76:2: error: expected primary-expression before '}' token
   76 |  }
      |  ^
dreaming.cpp:61:2: warning: label 'ios_base' defined but not used [-Wunused-label]
   61 |  ios_base:sync_with_stdio(false);
      |  ^~~~~~~~