답안 #113730

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
113730 2019-05-28T06:38:17 Z MAMBA CEOI16_icc (CEOI16_icc) C++17
컴파일 오류
0 ms 0 KB
#include "icc.h"
#include <bits/stdc++.h> 

using namespace std;

#define rep(i , j , k) for(int i = j ; i < (int)k; i++)
#define pb push_back

constexpr int N = 110;

int sz[N], par[N];
vector<int> vec[N];
set<int> st;

int getPAr(int v) {
	if (par[v] == -1) return v;
	return getPar(par[v]);
}

inline void merge(int u , int v) {
	v = getPar(v);
	u = getPar(u);

	if (sz[v] > sz[u]) swap(v , u);

	for (auto e : h[v])
		h[u].pb(e);
	h[v].clear();
	par[v] = u;
	sz[u] += sz[v];
	st.erase(v);
}

int a[N], b[N];

unordered_map<int , int> mp , arr;
int ptr;
inline void solve() {
	prt = 0;
	mp.clear();
	arr.clear();
	for (auto e : st) {
		arr[ptr] = e;
		mp[e] = ptr++;
	}	
	int xor_ = 0;
	for (int i = 0; (1 << i) <= ptr; i++) {
		int size_a = 0;
		int size_b = 0;
		rep(j , 0 , ptr) {
			if ((j >> i) & 1) {
				for (auto e : h[arr[j]])
					a[size_a++] = e;
			}
			else {
				for (auto e : h[arr[j]])
					b[size_b++] = e;
			}
		}
		xor_ |= (query(size_a , size_b , a , b) ? (1 << i) : 0);
	}
	int now_a = 0, int now_b = 0;
	now_b |= 1 << __builtin_ctz(xor_);
	for (int i = 0; (1 << i) <= ptr; i++) {
		if (b & (1 << i)) continue;
		if ((xor_ >> i) & 1) {
			int size_a = 0;
			int size_b = 0;
			rep(j , 0 , ptr) {
				int must = ((1 << __builtin_ctz(xor_)) | ((1 << i) - 1));
				if (j & must == nowa) {
					if ((j >> i) & 1) 
						for (auto e : h[arr[j]])
							a[size_a++] = e;
				}
				else if (j & must == nowb) {
					if ((j >> i) & 1) ;
					else 
						for (auto e: h[arr[j]])
							b[size_b++] = e;
				}
			}
			if (query(size_a , size_ , a , b))
				now_a += (1 << i);
			else
				now_b += (1 << i);
		}
		else {
			int size_a = 0;
			int size_b = 0;
			rep(j , 0 , ptr) {
				int must = ((1 << __builtin_ctz(xor_)) | ((1 << i) - 1));
				if (j & must == nowa) {
					if ((j >> i) & 1) 
						for (auto e : h[arr[j]])
							a[size_a++] = e;
				}
				else if (j & must == nowb) {
					if ((j >> i) & 1) 
						for (auto e : h[arr[j]])
							b[size_b++] = e;
				}
			}
			if (query(size_a , size_ , a , b)) {
				now_a += (1 << i);
				now_b += (1 << i);
			}
		}
	}

	now_a = arr[now_a];
	now_b = arr[now_b];
	int lo = 0,  hi = h[now_a].size();
	while (lo != hi - 1) {
		int mid = lo + hi >> 1;
		int size_a = 0;
		int size_b = 0;
		rep(i , 0 , mid)
			a[size_a++] = h[now_a][i];
		for (auto e : h[now_b])
			b[size_b++] = e;
		if (query(size_a , size_b , a , b))
			hi = mid;
		else lo = mid;
	}

	int man = lo;

	lo = 0, hi = h[now_b].size();
	while (lo != hi - 1) {
		int mid = lo + hi >> 1;
		a[0] = h[now_a][man];
		rep(i , 0 , mid)
			b[i] = h[now_b][i];
		if (query(1 , mid , a , b));
			hi = mid;
		else
			lo = mid;
	}
	setRoad(h[now_a][man] , h[now_b][lo]);
	merge(h[now_a][man] , h[now_b][lo]);
}

void run(int n) {
	rep(i , 1 , n + 1)
		st.insert(i);
	rep(i , 0 , n) 
		solve();
}

Compilation message

icc.cpp: In function 'int getPAr(int)':
icc.cpp:17:9: error: 'getPar' was not declared in this scope
  return getPar(par[v]);
         ^~~~~~
icc.cpp:17:9: note: suggested alternative: 'getPAr'
  return getPar(par[v]);
         ^~~~~~
         getPAr
icc.cpp: In function 'void merge(int, int)':
icc.cpp:21:6: error: 'getPar' was not declared in this scope
  v = getPar(v);
      ^~~~~~
icc.cpp:21:6: note: suggested alternative: 'getPAr'
  v = getPar(v);
      ^~~~~~
      getPAr
icc.cpp:26:16: error: 'h' was not declared in this scope
  for (auto e : h[v])
                ^
icc.cpp:28:2: error: 'h' was not declared in this scope
  h[v].clear();
  ^
icc.cpp: In function 'void solve()':
icc.cpp:39:2: error: 'prt' was not declared in this scope
  prt = 0;
  ^~~
icc.cpp:52:19: error: 'h' was not declared in this scope
     for (auto e : h[arr[j]])
                   ^
icc.cpp:56:19: error: 'h' was not declared in this scope
     for (auto e : h[arr[j]])
                   ^
icc.cpp:62:17: error: expected unqualified-id before 'int'
  int now_a = 0, int now_b = 0;
                 ^~~
icc.cpp:63:2: error: 'now_b' was not declared in this scope
  now_b |= 1 << __builtin_ctz(xor_);
  ^~~~~
icc.cpp:63:2: note: suggested alternative: 'now_a'
  now_b |= 1 << __builtin_ctz(xor_);
  ^~~~~
  now_a
icc.cpp:65:9: error: invalid operands of types 'int [110]' and 'int' to binary 'operator&'
   if (b & (1 << i)) continue;
       ~~^~~~~~~~~~
icc.cpp:71:21: error: 'nowa' was not declared in this scope
     if (j & must == nowa) {
                     ^~~~
icc.cpp:71:21: note: suggested alternative: 'now_a'
     if (j & must == nowa) {
                     ^~~~
                     now_a
icc.cpp:73:21: error: 'h' was not declared in this scope
       for (auto e : h[arr[j]])
                     ^
icc.cpp:76:26: error: 'nowb' was not declared in this scope
     else if (j & must == nowb) {
                          ^~~~
icc.cpp:76:26: note: suggested alternative: 'now_a'
     else if (j & must == nowb) {
                          ^~~~
                          now_a
icc.cpp:79:20: error: 'h' was not declared in this scope
       for (auto e: h[arr[j]])
                    ^
icc.cpp:83:23: error: 'size_' was not declared in this scope
    if (query(size_a , size_ , a , b))
                       ^~~~~
icc.cpp:83:23: note: suggested alternative: 'size_b'
    if (query(size_a , size_ , a , b))
                       ^~~~~
                       size_b
icc.cpp:93:21: error: 'nowa' was not declared in this scope
     if (j & must == nowa) {
                     ^~~~
icc.cpp:93:21: note: suggested alternative: 'now_a'
     if (j & must == nowa) {
                     ^~~~
                     now_a
icc.cpp:95:21: error: 'h' was not declared in this scope
       for (auto e : h[arr[j]])
                     ^
icc.cpp:98:26: error: 'nowb' was not declared in this scope
     else if (j & must == nowb) {
                          ^~~~
icc.cpp:98:26: note: suggested alternative: 'now_a'
     else if (j & must == nowb) {
                          ^~~~
                          now_a
icc.cpp:100:21: error: 'h' was not declared in this scope
       for (auto e : h[arr[j]])
                     ^
icc.cpp:104:23: error: 'size_' was not declared in this scope
    if (query(size_a , size_ , a , b)) {
                       ^~~~~
icc.cpp:104:23: note: suggested alternative: 'size_b'
    if (query(size_a , size_ , a , b)) {
                       ^~~~~
                       size_b
icc.cpp:113:20: error: 'h' was not declared in this scope
  int lo = 0,  hi = h[now_a].size();
                    ^
icc.cpp:113:20: note: suggested alternative: 'hi'
  int lo = 0,  hi = h[now_a].size();
                    ^
                    hi
icc.cpp:115:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   int mid = lo + hi >> 1;
             ~~~^~~~
icc.cpp:131:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   int mid = lo + hi >> 1;
             ~~~^~~~
icc.cpp:135:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   if (query(1 , mid , a , b));
   ^~
icc.cpp:136:4: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
    hi = mid;
    ^~
icc.cpp:137:3: error: 'else' without a previous 'if'
   else
   ^~~~