답안 #707106

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
707106 2023-03-08T13:12:46 Z minhcool CEOI16_icc (CEOI16_icc) C++17
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
#include "icc.h"
using namespace std;

//#define int long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;

const int N = 3e5 + 5;

const int oo = 1e18 + 7, mod = 1e9 + 7;

int n, rt[N], sz[N];

int root(int x){
	return (x == rt[x] ? x : rt[x] = root(rt[x]));
}

void merge(int x, int y){
	x = root(x), y = root(y);
	assert(x != y);
	if(sz[x] < sz[y]) swap(x, y);
	sz[x] += sz[y];
	rt[y] = x;
}

int ind[N];

void run(int N){
	n = N;
	for(int i = 1; i <= n; i++){
		rt[i] = i;
		sz[i] = 1;
	}
	int temp = n - 1;
	while(temp--){
		vector<int> v;
		for(int i = 1; i <= n; i++) if(root(i) == i) v.pb(i);
		vector<int> a, b;
		while(1){
			a.clear(), b.clear();
			random_shuffle(v.begin(), v.end());
			for(int i = 0; i < v.size(); i++) ind[v[i]] = i;
			for(int i = 1; i <= n; i++){
				if(ind[root(i)] < (v.size() / 2)) a.pb(i);
				else b.pb(i);
			}
			bool ck = query(a.size(), b.size(), a, b);
			if(ck) break;
		}
		int le = 0, ri = a.size() - 1;// first position to be correct
		while(le < ri){
			int mid = (le + ri) >> 1;
			vector<int> temp;
			for(int i = mid; i < a.size(); i++) temp.pb(a[i]);
			if(!query(temp.size(), b.size(), temp, b)) le = mid + 1;
			else ri = mid;
		}
		int val1 = a[le];
		a.clear();
		a.pb(val1);
		le = 0, ri = b.size() - 1;
		while(le < ri){
			int mid = (le + ri) >> 1;
			vector<int> temp;
			for(int i = mid; i < b.size(); i++) temp.pb(b[i]);
			if(!query(a.size(), temp.size(), a, temp)) le = mid + 1;
			else ri = mid;
		}
		int val2 = b[ri];
		setRoad(val1, val2);
		merge(val1, val2);
	}
}

/*
void process(){

}

signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t;
	cin >> t;
	while(t--) process();
}
*/

Compilation message

icc.cpp:17:21: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   17 | const int oo = 1e18 + 7, mod = 1e9 + 7;
      |                ~~~~~^~~
icc.cpp: In function 'void run(int)':
icc.cpp:49:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |    for(int i = 0; i < v.size(); i++) ind[v[i]] = i;
      |                   ~~^~~~~~~~~~
icc.cpp:51:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |     if(ind[root(i)] < (v.size() / 2)) a.pb(i);
      |        ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
icc.cpp:54:40: error: cannot convert 'std::vector<int>' to 'int*'
   54 |    bool ck = query(a.size(), b.size(), a, b);
      |                                        ^
      |                                        |
      |                                        std::vector<int>
In file included from icc.cpp:2:
icc.h:10:30: note:   initializing argument 3 of 'int query(int, int, int*, int*)'
   10 | int query(int a, int b, int *A, int *B);
      |                         ~~~~~^
icc.cpp:61:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |    for(int i = mid; i < a.size(); i++) temp.pb(a[i]);
      |                     ~~^~~~~~~~~~
icc.cpp:62:37: error: cannot convert 'std::vector<int>' to 'int*'
   62 |    if(!query(temp.size(), b.size(), temp, b)) le = mid + 1;
      |                                     ^~~~
      |                                     |
      |                                     std::vector<int>
In file included from icc.cpp:2:
icc.h:10:30: note:   initializing argument 3 of 'int query(int, int, int*, int*)'
   10 | int query(int a, int b, int *A, int *B);
      |                         ~~~~~^
icc.cpp:72:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |    for(int i = mid; i < b.size(); i++) temp.pb(b[i]);
      |                     ~~^~~~~~~~~~
icc.cpp:73:37: error: cannot convert 'std::vector<int>' to 'int*'
   73 |    if(!query(a.size(), temp.size(), a, temp)) le = mid + 1;
      |                                     ^
      |                                     |
      |                                     std::vector<int>
In file included from icc.cpp:2:
icc.h:10:30: note:   initializing argument 3 of 'int query(int, int, int*, int*)'
   10 | int query(int a, int b, int *A, int *B);
      |                         ~~~~~^