Submission #632283

# Submission time Handle Problem Language Result Execution time Memory
632283 2022-08-19T19:43:58 Z Cyber_Wolf ICC (CEOI16_icc) C++14
0 / 100
1 ms 340 KB
//CEOI '16 P1
//Problem: ICC
//Link: https://oj.uz/problem/view/CEOI16_icc

#include <bits/stdc++.h>
#include "icc.h"

using namespace std;

#define lg long long

const lg MOD = 1e9+7, N = 101, M = 1e7+1, SZ = 1e3+1;

lg par[N], compSize[N];
vector<lg> child[N];

lg getParent(lg src)
{
	if(src == par[src])	return src;
	return par[src] = getParent(par[src]);
}

void join(lg u, lg v)
{
	u = getParent(u), v = getParent(v);
	if(u == v)	return;
	if(compSize[u] > compSize[v])	swap(u, v);
	par[u] = v;
	for(auto it : child[u])	child[v].push_back(it);
	compSize[v] += compSize[u];
}


void run(int n)
{
	for(int i = 1; i <= n; i++)	par[i] = i, compSize[i] = 1, child[i].push_back(i);
	lg x = n-1;
	while(x--)
	{
		vector<lg> parents;
		for(int i = 1; i <= n; i++)	if(par[i] == i)	parents.push_back(i);
		bool cur = true;
		for(int i = 0; i < parents.size() && cur; i++)
		{
			for(int j = i+1; j < parents.size() && cur; j++)
			{
				int a[child[parents[i]].size()], b[child[parents[j]].size()];
				for(int k = 0; k < child[parents[i]].size(); k++)
				{
					a[k] = child[parents[i]][k];
				}
				for(int k = 0; k < child[parents[j]].size(); k++)
				{
					b[k] = child[parents[j]][k];
				}
				bool flag = query(parents[i], parents[j], a, b);
				if(flag)
				{
					join(parents[i], parents[j]);
					setRoad(parents[i], parents[j]);
					cur = false;
					break;
				}
			}
		}
	}
}

Compilation message

icc.cpp: In function 'void run(int)':
icc.cpp:43:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |   for(int i = 0; i < parents.size() && cur; i++)
      |                  ~~^~~~~~~~~~~~~~~~
icc.cpp:45:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |    for(int j = i+1; j < parents.size() && cur; j++)
      |                     ~~^~~~~~~~~~~~~~~~
icc.cpp:48:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |     for(int k = 0; k < child[parents[i]].size(); k++)
      |                    ~~^~~~~~~~~~~~~~~~~~~~~~~~~~
icc.cpp:52:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |     for(int k = 0; k < child[parents[j]].size(); k++)
      |                    ~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Query cities not in range [1, n]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 300 KB Query cities not in range [1, n]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Query cities not in range [1, n]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Query cities not in range [1, n]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Query cities not in range [1, n]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Query cities not in range [1, n]
2 Halted 0 ms 0 KB -