답안 #546018

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
546018 2022-04-06T04:29:47 Z blue CEOI16_icc (CEOI16_icc) C++17
컴파일 오류
0 ms 0 KB
#include "icc.h"
#include <vector>
#include <algorithm>
using namespace std;

using vi = vector<int>;
using vvi = vector<vi>;
#define sz(x) int(x.size())

const int mx = 100;

int vquery(vi A, vi B)
{
	int a[mx], b[mx];
	for(int ai = 0; ai < sz(A); ai++)
		a[ai] = A[ai];

	for(int bi = 0; bi < sz(B); bi++)
		b[bi] = B[bi];

	if(sz(A) == 0 || sz(B) == 0)
		return 0;

	return query(sz(A), a, sz(B), b);
}

void run(int N)
{
	vi edge[1+N];

	for(int e = 1; e <= N-1; e++)
	{
		vi cc(1+N, 0);
		int ccc = 0;

		for(int i = 1; i <= N; i++)
		{
			if(cc[i]) continue;
			ccc++;

			queue<int> tbv;
			tbv.push(i);

			while(!tbv.empty())
			{
				int u = tbv.front();
				tbv.pop();

				cc[u] = ccc;

				for(int v : edge[u])
				{
					if(cc[v]) continue;
					tbv.push(v);
				}
			}
		}

		int k = 0;
		while((1<<k) < N)
			k++;

		vi bits;
		for(int v = 0; v < k; v++)
			bits.push_back(v);

		for(int t = 0; t < 2'000; t++)
		{
			int p = getRandom(0, k-1);
			int q = getRandom(0, k-1);
			swap(bits[p], bits[q]);
		}

		int goodbit;
		vi S[2];

		for(int b : bits)
		{
			vi s[2];
			for(int i = 1; i <= N; i++)
				s[bool(cc[i] & (1 << b))].push_back(b);

			if(vquery(s[0], s[1]))
			{
				goodbit = b;
				S[0] = s[0];
				S[1] = s[1];
				break;
			}
		}

		while(sz(S[0]) > 1)
		{
			vi SS[2];
			for(int i = 0; i < sz(S[0])/2; i++)
				SS[0].push_back(S[0][i]);
			for(int i = sz(S[0])/2; i < sz(S[0]); i++)
				SS[1].push_back(S[0][i]);

			if(vquery(SS[0], S[1]))
				S[0] = SS[0];
			else
				S[0] = SS[1];
		}

		while(sz(S[1]) > 1)
		{
			vi SS[2];
			for(int i = 0; i < sz(S[1])/2; i++)
				SS[0].push_back(S[1][i]);
			for(int i = sz(S[1])/2; i < sz(S[1]); i++)
				SS[1].push_back(S[1][i]);

			if(vquery(SS[0], S[0]))
				S[1] = SS[0];
			else
				S[1] = SS[1];
		}
		
		int u = S[0][0], v = S[1][0];
		setRoad(u, v)
		edge[u].push_back(v);
		edge[v].push_back(u);
	}
}

Compilation message

icc.cpp: In function 'int vquery(vi, vi)':
icc.cpp:24:22: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   24 |  return query(sz(A), a, sz(B), b);
      |                      ^
      |                      |
      |                      int*
In file included from icc.cpp:1:
icc.h:10:22: note:   initializing argument 2 of 'int query(int, int, int*, int*)'
   10 | int query(int a, int b, int *A, int *B);
      |                  ~~~~^
icc.cpp:8:15: error: invalid conversion from 'int' to 'int*' [-fpermissive]
    8 | #define sz(x) int(x.size())
      |               ^~~~~~~~~~~~~
      |               |
      |               int
icc.cpp:24:25: note: in expansion of macro 'sz'
   24 |  return query(sz(A), a, sz(B), b);
      |                         ^~
In file included from icc.cpp:1:
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: In function 'void run(int)':
icc.cpp:41:4: error: 'queue' was not declared in this scope
   41 |    queue<int> tbv;
      |    ^~~~~
icc.cpp:4:1: note: 'std::queue' is defined in header '<queue>'; did you forget to '#include <queue>'?
    3 | #include <algorithm>
  +++ |+#include <queue>
    4 | using namespace std;
icc.cpp:41:10: error: expected primary-expression before 'int'
   41 |    queue<int> tbv;
      |          ^~~
icc.cpp:42:4: error: 'tbv' was not declared in this scope
   42 |    tbv.push(i);
      |    ^~~
icc.cpp:69:12: error: 'getRandom' was not declared in this scope
   69 |    int p = getRandom(0, k-1);
      |            ^~~~~~~~~
icc.cpp:121:16: error: expected ';' before 'edge'
  121 |   setRoad(u, v)
      |                ^
      |                ;
  122 |   edge[u].push_back(v);
      |   ~~~~