Submission #625334

# Submission time Handle Problem Language Result Execution time Memory
625334 2022-08-10T05:11:42 Z OrazB Connecting Supertrees (IOI20_supertrees) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "supertrees.h"
#define N 1005
#define wr cout << "Continue debugging\n";
#define ll long long int
#define pii pair <int, int>
#define pb push_back
#define ff first
#define ss second
using namespace std;

int col[N], p[N][N], k[N], b[N][N], m[N];
vector <int> e[N];

int construct (vector <vector<int>> p){
	int cnt = 0;
	for (int i = 0; i < p.size(); i++){
		for (int j = 0; j < p[i].size(); j++) if (p[i][j] != p[j][i]) return 0;
	}
	for (int i = 0; i < p.size(); i++){
		if (!col[i]) cnt++, col[i] = cnt;
		for (int j = 0; j < p[i].size(); j++){
			if (!p[i][j]) continue; 
			col[j] = col[i];
			if (p[i][j] != 1 and k[col[i]] and k[col[i]] != p[i][j]) return 0;
			else if (p[i][j] != 1) k[col[i]] = p[i][j];
		}
	}
	for (int i = 0; i < p.size(); i++) if (!k[col[i]]) k[col[i]] = 1;
	for (int i = 0; i < p.size(); i++){
		cnt = 0;
		for (int j = 0; j < p[i].size(); j++) if (p[i][j] == k[col[i]]) cnt++;
		if (cnt < k[col[i]]) return 0;
	}
	cnt = 0;
	for (int i = 0; i < p.size(); i++){
		if (m[i]){
			for (int j = 0; j < p[i].size(); j++) if (e[m[i]][j] != p[i][j]) return 0;
			continue;
		}
		cnt++;
		for (int j = 0; j < p[i].size(); j++) e[cnt].pb(p[i][j]);
		for (int j = 0; j < p[i].size(); j++){
			if (i == j or p[i][j] != 1 or m[j]) continue;
			b[i][j] = b[j][i] = 1; m[j] = cnt;
		}
	}
	for (int i = 0; i < p.size(); i++){
		if (m[i]) continue;
		for (int j = 0; j < p[i].size(); j++){
			if (p[i][j] < 2 or m[j]) continue;
			b[i][j] = b[j][i] = 1;
		}
	}
	build(b);
	// for (int i = 0; i < p.size(); i++){
	// 	for (int j = 0; j < p[i].size(); j++) cout << b[i][j] << " ";
	// 	cout << '\n';
	// }
	return 1;
}
// int main ()
// {
// 	ios::sync_with_stdio(false);
// 	cin.tie(0);
// 	int n;
// 	cin >> n;
// 	vector<vector<int>> afk(n, vector <int> (n));
// 	for (int i = 0; i < n; i++){
// 		for (int j = 0; j < n; j++) cin >> afk[i][j];
// 	}
// 	cout << construct(afk);
// }	

Compilation message

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:17:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |  for (int i = 0; i < p.size(); i++){
      |                  ~~^~~~~~~~~~
supertrees.cpp:18:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |   for (int j = 0; j < p[i].size(); j++) if (p[i][j] != p[j][i]) return 0;
      |                   ~~^~~~~~~~~~~~~
supertrees.cpp:20:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |  for (int i = 0; i < p.size(); i++){
      |                  ~~^~~~~~~~~~
supertrees.cpp:22:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |   for (int j = 0; j < p[i].size(); j++){
      |                   ~~^~~~~~~~~~~~~
supertrees.cpp:29:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |  for (int i = 0; i < p.size(); i++) if (!k[col[i]]) k[col[i]] = 1;
      |                  ~~^~~~~~~~~~
supertrees.cpp:30:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |  for (int i = 0; i < p.size(); i++){
      |                  ~~^~~~~~~~~~
supertrees.cpp:32:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |   for (int j = 0; j < p[i].size(); j++) if (p[i][j] == k[col[i]]) cnt++;
      |                   ~~^~~~~~~~~~~~~
supertrees.cpp:36:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |  for (int i = 0; i < p.size(); i++){
      |                  ~~^~~~~~~~~~
supertrees.cpp:38:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |    for (int j = 0; j < p[i].size(); j++) if (e[m[i]][j] != p[i][j]) return 0;
      |                    ~~^~~~~~~~~~~~~
supertrees.cpp:42:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |   for (int j = 0; j < p[i].size(); j++) e[cnt].pb(p[i][j]);
      |                   ~~^~~~~~~~~~~~~
supertrees.cpp:43:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |   for (int j = 0; j < p[i].size(); j++){
      |                   ~~^~~~~~~~~~~~~
supertrees.cpp:48:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |  for (int i = 0; i < p.size(); i++){
      |                  ~~^~~~~~~~~~
supertrees.cpp:50:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |   for (int j = 0; j < p[i].size(); j++){
      |                   ~~^~~~~~~~~~~~~
supertrees.cpp:55:8: error: could not convert '(int (*)[1005])(& b)' from 'int (*)[1005]' to 'std::vector<std::vector<int> >'
   55 |  build(b);
      |        ^
      |        |
      |        int (*)[1005]