Submission #604670

# Submission time Handle Problem Language Result Execution time Memory
604670 2022-07-25T08:41:36 Z maximath_1 ICC (CEOI16_icc) C++11
90 / 100
138 ms 496 KB
#include <bits/stdc++.h>
#include "icc.h"
using namespace std;
 
const int MX = 105;
 
int par[MX];
int find(int nw){
	return par[nw] = (par[nw] == nw ? nw : find(par[nw]));
}
mt19937 rng(0);
void run(int N){
	for(int i = 1; i <= N; i ++)
		par[i] = i;
	for(int times = 1; times < N; times ++){
		vector<int> color(N + 1, -1), lf, rg;
		int gt = 0;
		
		for(int xx = 0; xx < 7; xx ++){
			int i = xx;
			int tp = 1;
			for(int j = 1; j <= N; j ++) if(find(j) == j){
				if(tp & (1 << i)) color[j] = 1;
				else color[j] = 0;
				tp ++;
			}
			for(int j = 1; j <= N; j ++) color[j] = color[find(j)];
			lf.clear(); rg.clear();
			for(int j = 1; j <= N; j ++)
				if(color[j] == 1) lf.push_back(j);
				else rg.push_back(j);
			int xl[lf.size()], xr[rg.size()];
			for(int i = 0; i < lf.size(); i ++) xl[i] = lf[i];
			for(int i = 0; i < rg.size(); i ++) xr[i] = rg[i];
			if(lf.empty() || rg.empty()) continue;
			gt = query(lf.size(), rg.size(), xl, xr);
			if(gt == 1) break;
		}
 	
		int l = 0, r = (int)rg.size() - 2, rs = r + 1;
		for(int md; l <= r;){
			md = (l + r) / 2;
			vector<int> nrg;
			for(int j = 0; j <= md; j ++) nrg.push_back(rg[j]);
			int xl[lf.size()], xr[nrg.size()];
			for(int i = 0; i < lf.size(); i ++) xl[i] = lf[i];
			for(int i = 0; i < nrg.size(); i ++) xr[i] = nrg[i];
			gt = query(lf.size(), nrg.size(), xl, xr);
		
			if(gt){
				rs = md; r = md - 1;
			}else{
				l = md + 1;
			}
		}
 
		int u = rg[rs]; rg.clear(); rg.push_back(u);
		swap(lf, rg);
 
		l = 0, r = (int)rg.size() - 2, rs = r + 1;
		for(int md; l <= r;){
			md = (l + r) / 2;
			vector<int> nrg;
			for(int j = 0; j <= md; j ++) nrg.push_back(rg[j]);
			int xl[lf.size()], xr[nrg.size()];
			for(int i = 0; i < lf.size(); i ++) xl[i] = lf[i];
			for(int i = 0; i < nrg.size(); i ++) xr[i] = nrg[i];
			gt = query(lf.size(), nrg.size(), xl, xr);
			if(gt){
				rs = md; r = md - 1;
			}else{
				l = md + 1;
			}
		}
 
		int v = rg[rs];
 
		setRoad(u, v);
		u = find(u); v = find(v);
		par[u] = v;
	}
}

Compilation message

icc.cpp: In function 'void run(int)':
icc.cpp:33:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |    for(int i = 0; i < lf.size(); i ++) xl[i] = lf[i];
      |                   ~~^~~~~~~~~~~
icc.cpp:34:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |    for(int i = 0; i < rg.size(); i ++) xr[i] = rg[i];
      |                   ~~^~~~~~~~~~~
icc.cpp:46:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |    for(int i = 0; i < lf.size(); i ++) xl[i] = lf[i];
      |                   ~~^~~~~~~~~~~
icc.cpp:47:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |    for(int i = 0; i < nrg.size(); i ++) xr[i] = nrg[i];
      |                   ~~^~~~~~~~~~~~
icc.cpp:66:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |    for(int i = 0; i < lf.size(); i ++) xl[i] = lf[i];
      |                   ~~^~~~~~~~~~~
icc.cpp:67:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |    for(int i = 0; i < nrg.size(); i ++) xr[i] = nrg[i];
      |                   ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 468 KB Ok! 96 queries used.
2 Correct 4 ms 468 KB Ok! 103 queries used.
# Verdict Execution time Memory Grader output
1 Correct 29 ms 468 KB Ok! 529 queries used.
2 Correct 35 ms 468 KB Ok! 698 queries used.
3 Correct 37 ms 468 KB Ok! 676 queries used.
# Verdict Execution time Memory Grader output
1 Correct 100 ms 468 KB Ok! 1485 queries used.
2 Correct 123 ms 484 KB Ok! 1676 queries used.
3 Correct 117 ms 484 KB Ok! 1598 queries used.
4 Correct 108 ms 468 KB Ok! 1533 queries used.
# Verdict Execution time Memory Grader output
1 Correct 101 ms 488 KB Ok! 1552 queries used.
2 Correct 107 ms 488 KB Ok! 1560 queries used.
3 Correct 107 ms 468 KB Ok! 1678 queries used.
4 Correct 106 ms 496 KB Ok! 1533 queries used.
# Verdict Execution time Memory Grader output
1 Correct 115 ms 480 KB Ok! 1651 queries used.
2 Correct 110 ms 488 KB Ok! 1672 queries used.
3 Correct 105 ms 468 KB Ok! 1620 queries used.
4 Correct 103 ms 488 KB Ok! 1636 queries used.
5 Correct 104 ms 480 KB Ok! 1501 queries used.
6 Correct 102 ms 496 KB Ok! 1556 queries used.
# Verdict Execution time Memory Grader output
1 Incorrect 138 ms 488 KB Too many queries! 1677 out of 1625
2 Halted 0 ms 0 KB -