답안 #604572

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
604572 2022-07-25T07:47:22 Z maximath_1 CEOI16_icc (CEOI16_icc) C++11
61 / 100
159 ms 500 KB
#include <bits/stdc++.h>
#include "icc.h"
using namespace std;
 
const int MX = 1005;
 
int par[MX];
int find(int nw){
	return par[nw] = (par[nw] == nw ? nw : find(par[nw]));
}
mt19937 rng(time(NULL));
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;
		do{
			for(int i = 1; i <= N; i ++) if(find(i) == i)
				color[i] = rng() % 2;
			for(int i = 1; i <= N; i ++) color[i] = color[find(i)];
			lf.clear(); rg.clear();
			for(int i = 1; i <= N; i ++)
				if(color[i]) rg.push_back(i);
				else lf.push_back(i);
			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];
			gt = query(lf.size(), rg.size(), xl, xr);
		}while(gt == 0);
 
		int l = 0, r = rg.size() - 1, 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 = rg.size() - 1, 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:27:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |    for(int i = 0; i < lf.size(); i ++) xl[i] = lf[i];
      |                   ~~^~~~~~~~~~~
icc.cpp:28:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |    for(int i = 0; i < rg.size(); i ++) xr[i] = rg[i];
      |                   ~~^~~~~~~~~~~
icc.cpp:38:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |    for(int i = 0; i < lf.size(); i ++) xl[i] = lf[i];
      |                   ~~^~~~~~~~~~~
icc.cpp:39:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |    for(int i = 0; i < nrg.size(); i ++) xr[i] = nrg[i];
      |                   ~~^~~~~~~~~~~~
icc.cpp:57:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |    for(int i = 0; i < lf.size(); i ++) xl[i] = lf[i];
      |                   ~~^~~~~~~~~~~
icc.cpp:58:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |    for(int i = 0; i < nrg.size(); i ++) xr[i] = nrg[i];
      |                   ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 468 KB Ok! 115 queries used.
2 Correct 6 ms 468 KB Ok! 110 queries used.
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 484 KB Ok! 559 queries used.
2 Correct 46 ms 484 KB Ok! 862 queries used.
3 Correct 42 ms 500 KB Ok! 825 queries used.
# 결과 실행 시간 메모리 Grader output
1 Correct 113 ms 468 KB Ok! 1552 queries used.
2 Correct 159 ms 492 KB Ok! 2158 queries used.
3 Correct 117 ms 488 KB Ok! 1728 queries used.
4 Correct 125 ms 484 KB Ok! 1737 queries used.
# 결과 실행 시간 메모리 Grader output
1 Correct 132 ms 500 KB Ok! 1753 queries used.
2 Correct 125 ms 488 KB Ok! 1739 queries used.
3 Correct 133 ms 484 KB Ok! 1901 queries used.
4 Correct 121 ms 488 KB Ok! 1595 queries used.
# 결과 실행 시간 메모리 Grader output
1 Incorrect 153 ms 480 KB Too many queries! 1928 out of 1775
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 139 ms 488 KB Too many queries! 1917 out of 1625
2 Halted 0 ms 0 KB -