답안 #124057

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
124057 2019-07-02T12:34:32 Z eriksuenderhauf CEOI16_icc (CEOI16_icc) C++11
컴파일 오류
0 ms 0 KB
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include "icc.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define mem(a,v) memset((a), (v), sizeof (a))
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%I64d", &(n))
#define nai(a, n) for (int i = 0; i < (n); i++) ni(a[i])
#define nal(a, n) for (int i = 0; i < (n); i++) nl(a[i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%I64d\n", (n))
#define pii pair<int, int>
#define pil pair<int, long long>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vil vector<pil>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int MAXN = 1e2 + 5;
const double eps = 1e-9;
int par[MAXN], sz[MAXN];
vi comp[MAXN];

int qry(int x) { return par[x] == x ? par[x] : qry(par[x]); }
void join(int u, int v) {
	u = qry(u), v = qry(v);
	if (u == v) return;
	if (sz[u] > sz[v]) swap(u, v);
	par[u] = v;
	comp[v].insert(comp[v].end(), comp[u].begin(), comp[u].end());
}

pii solve(int N) {
	pii ret;
	vi cand;
	for (int i = 1; i <= N; i++) {
		if (qry(i) != i)
			continue;
		cand.pb(i);
	}
	vi l, r;
	int cl = 0, cr = 0, ind = 0;
	for (; (1<<ind) < (int)cand.size(); ind++) {
		l.clear();
		r.clear();
		cl = 0, cr = 0;
		for (int j = 0; j < (int)cand.size(); j++) {
			if ((j >> ind) & 1)
				l.insert(l.end(), comp[cand[j]].begin(), comp[cand[j]].end()), cl++;
			else
				r.insert(r.end(), comp[cand[j]].begin(), comp[cand[j]].end()), cr++;
		}
		int fl = query((int)l.size(),(int)r.size(), l, r);
		if (fl == 1)
			break;
	}
	int lo = 0, hi = cl;
	while (lo <= hi) {
		int mi = (lo+hi) / 2, cur = 0;
		vi tmp;
		for (int i = 0; i < (int)cand.size() && cur <= mi; i++)
			if ((j >> ind) & 1)
				tmp.insert(tmp.end(), comp[cand[i]].begin(), comp[cand[i]].end()), cur++;
		int fl = query((int)tmp.size(),(int)r.size(), tmp, r);
		if (fl == 1)
			hi = mi - 1;
		else
			lo = mi + 1;
	}
	ret.fi = lo;
	lo = 0, hi = cr;
	while (lo <= hi) {
		int mi = (lo+hi) / 2, cur = 0;
		vi tmp;
		for (int i = 0; i < (int)cand.size() && cur <= mi; i++)
			if (!((j >> ind) & 1))
				tmp.insert(tmp.end(), comp[cand[i]].begin(), comp[cand[i]].end()), cur++;
		int fl = query((int)l.size(),(int)tmp.size(), l, tmp);
		if (fl == 1)
			hi = mi - 1;
		else
			lo = mi + 1;
	}
	ret.se = lo;
	return ret;
}


void run(int N) {
	for (int i = 1; i <= N; i++)
		par[i] = i, sz[i] = 1, comp[i] = {i};
	for (int t = 1; t < N; t++) {
		int a, b;
		tie(a, b) = solve(N);
		pii nx;
		vi l = comp[a], r = comp[b];
		int lo = 0, hi = l.size()-1;
		while (lo <= hi) {
			int mi = (lo+hi) / 2;
			vi tmp;
			for (int i = 0; i <= mi; i++)
				tmp.pb(l[i]);
			int fl = query((int)tmp.size(),(int)r.size(), tmp, r);
			if (fl == 1)
				hi = mi - 1;
			else
				lo = mi + 1;
		}
		nx.fi = lo;
		lo = 0, hi = r.size()-1;
		while (lo <= hi) {
			int mi = (lo+hi) / 2;
			vi tmp;
			for (int i = 0; i <= mi; i++)
				tmp.pb(l[i]);
			int fl = query((int)l.size(),(int)tmp.size(), l, tmp);
			if (fl == 1)
				hi = mi - 1;
			else
				lo = mi + 1;
		}
		nx.se = lo;
		setRoad(nx.fi, nx.se);
		join(nx.fi, nx.se);
	}
}

Compilation message

icc.cpp: In function 'std::pair<int, int> solve(int)':
icc.cpp:70:51: error: cannot convert 'std::vector<int>' to 'int*' for argument '3' to 'int query(int, int, int*, int*)'
   int fl = query((int)l.size(),(int)r.size(), l, r);
                                                   ^
icc.cpp:79:9: error: 'j' was not declared in this scope
    if ((j >> ind) & 1)
         ^
icc.cpp:81:55: error: cannot convert 'std::vector<int>' to 'int*' for argument '3' to 'int query(int, int, int*, int*)'
   int fl = query((int)tmp.size(),(int)r.size(), tmp, r);
                                                       ^
icc.cpp:93:11: error: 'j' was not declared in this scope
    if (!((j >> ind) & 1))
           ^
icc.cpp:95:55: error: cannot convert 'std::vector<int>' to 'int*' for argument '3' to 'int query(int, int, int*, int*)'
   int fl = query((int)l.size(),(int)tmp.size(), l, tmp);
                                                       ^
icc.cpp: In function 'void run(int)':
icc.cpp:120:56: error: cannot convert 'std::vector<int>' to 'int*' for argument '3' to 'int query(int, int, int*, int*)'
    int fl = query((int)tmp.size(),(int)r.size(), tmp, r);
                                                        ^
icc.cpp:133:56: error: cannot convert 'std::vector<int>' to 'int*' for argument '3' to 'int query(int, int, int*, int*)'
    int fl = query((int)l.size(),(int)tmp.size(), l, tmp);
                                                        ^