Submission #632315

# Submission time Handle Problem Language Result Execution time Memory
632315 2022-08-19T20:33:52 Z Cyber_Wolf ICC (CEOI16_icc) C++14
7 / 100
286 ms 488 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];

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;
	compSize[v] += compSize[u];
}


void run(int n)
{
	for(int i = 1; i <= n; i++)	par[i] = i, compSize[i] = 1;
	lg x = n-1;
	while(x--)
	{
		for(int i = 1; i <= n; i++)
		{
			vector<lg> v;
			for(int j = 1; j <= n; j++)	if(getParent(i) != getParent(j))	v.push_back(j);
			int arr[v.size()];
			for(int j = 0; j < v.size(); j++)	arr[j] = v[j];
			int h[1] = {i};
			bool flag = query(1, v.size(), h, arr);
			if(!flag)	continue;
			for(auto it : v)
			{
				int g[] = {it};
				bool cur = query(1, 1, h, g);
				if(cur)
				{
					join(h[0], g[0]);
					setRoad(h[0], g[0]);
					break;
				}
			}
		}
	}
}

Compilation message

icc.cpp: In function 'void run(int)':
icc.cpp:43:21: 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 j = 0; j < v.size(); j++) arr[j] = v[j];
      |                   ~~^~~~~~~~~~
icc.cpp:49:16: warning: narrowing conversion of 'it' from 'long long int' to 'int' [-Wnarrowing]
   49 |     int g[] = {it};
      |                ^~
# Verdict Execution time Memory Grader output
1 Correct 11 ms 468 KB Ok! 290 queries used.
2 Correct 12 ms 468 KB Ok! 266 queries used.
# Verdict Execution time Memory Grader output
1 Incorrect 155 ms 488 KB Too many queries! 3501 out of 2500
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 286 ms 468 KB Number of queries more than 4500 out of 2250
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 252 ms 468 KB Number of queries more than 4000 out of 2000
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 217 ms 476 KB Number of queries more than 3550 out of 1775
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 218 ms 480 KB Number of queries more than 3250 out of 1625
2 Halted 0 ms 0 KB -