QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#424754#5029. 在路上Estelle_NCompile Error//C++141.9kb2024-05-29 16:47:252024-05-29 16:47:26

Judging History

你现在查看的是最新测评结果

  • [2024-05-29 16:47:26]
  • 评测
  • [2024-05-29 16:47:25]
  • 提交

answer

#include "path.h"
#include <cstdio>
#include <cstdlib>
#include <algorithm>

using namespace std;

const int N = 300005;

int cnt, tot, a[N], b[N], p[N], q[N];

int solve(int N)
{
	cnt = tot = 0;
	for(int i = 1; i <= N; ++ i)
		a[i] = b[i] = 0;

	int x = rand() % N + 1, y = rand() % N + 1;
	while(x == y)
		y = rand() % N + 1;

	for(int i = 1; i <= N; ++ i)
	{
		if(i == x || i == y)
			continue;
		int u = ask(i, x, y);
		if(u == 0)
			a[i] = 0, p[++cnt] = i;
		else if(u == i)
			a[i] = 1, q[++tot] = i, p[++cnt] = i;
		else if(u == x)	
			a[i] = 2;
		else
			a[i] = 3;
	}

	// printf("%d %d\n", x, y);

	int z = cnt ? p[rand() % cnt + 1] : x, u;
	for(int i = 1; i <= tot; ++ i)
	{
		if(q[i] == z || (ask(z, q[i], x) == q[i] && ask(z, q[i], y) == q[i]))
		{
			u = q[i];
			break;
		}
	}

	// printf("%d\n", u);

	int v = x, s1 = 1;
	for(int i = 1; i <= tot; ++ i)
		if(p[i] != u && ask(p[i], v, u) == p[i])
			v = p[i];
	for(int i = 1; i <= N; ++ i)
		if(i != u && i != v)
			if(ask(i, v, u) == v)
				++ s1, b[i] = 1;

	if(s1 > N / 2)
		return -1;
	
	int w = y, s2 = 1;
	for(int i = 1; i <= tot; ++ i)
		if(p[i] != u && ask(p[i], w, u) == p[i])
			w = p[i];
	for(int i = 1; i <= N; ++ i)
		if(i != u && i != w)
			if(ask(i, w, u) == w)
				++ s2, b[i] = 1;

	if(s2 > N / 2)
		return -1;

	if(N - s1 - s2 - 1 <= N / 2)
		return u;
	
	int sum = 0, k = 0;
	for(int i = 1; i <= N; ++ i)
	{
		if(!b[i] && i != v && i != w && i != u)
		{
			if(sum == 0)
				k = i, ++ sum;
			else if(ask(i, u, k))
				++ sum;
			else
				-- sum;
		}
	}

	sum = 0;
	for(int i = 1; i <= N; ++ i)
		if(!b[i] && i != v && i != w && i != u && i != k)
			sum += (ask(i, u, k) != 0);
	
	if(sum > N / 2)
		return -1;

	return u;
}

int centroid(int id, int N, int M)
{
	if(id == 1)
		return get(1, 2, 3);

	int u = solve(N);
	while(u == -1)
		u = solve(N);

	printf("%d\n", u);
	return u;
}

詳細信息

implementer.cpp: In function ‘int main()’:
implementer.cpp:60:14: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   60 |         fread(Interactor::rbuf,1,50000000,stdin);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
answer.code: In function ‘int centroid(int, int, int)’:
answer.code:106:27: error: no matching function for call to ‘get(int, int, int)’
  106 |                 return get(1, 2, 3);
      |                        ~~~^~~~~~~~~
In file included from /usr/include/c++/13/bits/stl_algobase.h:64,
                 from /usr/include/c++/13/algorithm:60,
                 from answer.code:4:
/usr/include/c++/13/bits/stl_pair.h:1035:5: note: candidate: ‘template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(pair<_Tp1, _Tp2>&)’
 1035 |     get(pair<_Tp1, _Tp2>& __in) noexcept
      |     ^~~
/usr/include/c++/13/bits/stl_pair.h:1035:5: note:   template argument deduction/substitution failed:
answer.code:106:27: note:   mismatched types ‘std::pair<_Tp1, _Tp2>’ and ‘int’
  106 |                 return get(1, 2, 3);
      |                        ~~~^~~~~~~~~
/usr/include/c++/13/bits/stl_pair.h:1040:5: note: candidate: ‘template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(pair<_Tp1, _Tp2>&&)’
 1040 |     get(pair<_Tp1, _Tp2>&& __in) noexcept
      |     ^~~
/usr/include/c++/13/bits/stl_pair.h:1040:5: note:   template argument deduction/substitution failed:
answer.code:106:27: note:   mismatched types ‘std::pair<_Tp1, _Tp2>’ and ‘int’
  106 |                 return get(1, 2, 3);
      |                        ~~~^~~~~~~~~
/usr/include/c++/13/bits/stl_pair.h:1045:5: note: candidate: ‘template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(const pair<_Tp1, _Tp2>&)’
 1045 |     get(const pair<_Tp1, _Tp2>& __in) noexcept
      |     ^~~
/usr/include/c++/13/bits/stl_pair.h:1045:5: note:   template argument deduction/substitution failed:
answer.code:106:27: note:   mismatched types ‘const std::pair<_Tp1, _Tp2>’ and ‘int’
  106 |                 return get(1, 2, 3);
      |                        ~~~^~~~~~~~~
/usr/include/c++/13/bits/stl_pair.h:1050:5: note: candidate: ‘template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(const pair<_Tp1, _Tp2>&&)’
 1050 |     get(const pair<_Tp1, _Tp2>&& __in) noexcept
      |     ^~~
/usr/include/c++/13/bits/stl_pair.h:1050:5: note:   template argument deduction/substitution failed:
answer.code:106:27: note:   mismatched types ‘const std::pair<_Tp1, _Tp2>’ and ‘int’
  106 |                 return get(1, 2, 3);
      |                        ~~~^~~~~~~~~
/usr/include/c++/13/bits/stl_pair.h:1059:5: note: candidate: ‘template<class _Tp, class _Up> constexpr _Tp& std::get(pair<_T1, _T2>&)’
 1059 |     get(pair<_Tp, _Up>& __p) noexcept
      |     ^~~
/usr/include/c++/13/bits/stl_pair.h:1059:5: note:   template argument deduction/substitution failed:
answer.code:106:27: note:   mismatched types ‘std::pair<_T1, _T2>’ and ‘int’
  106 |                 return get(1, 2, 3);
      |                        ~~~^~~~~~~~~
/usr/include/c++/13/bits/stl_pair.h:1064:5: note: candidate: ‘template<class _Tp, class _Up> constexpr const _Tp& std::get(const pair<_T1, _T2>&)’
 1064 |     get(const pair<_Tp, _Up>& __p) noexcept
      |     ^~~
/usr/include/c++/13/bits/stl_pair.h:1064:5: note:   template argument deduction/substitution failed:
answer.code:106:27: note:   mismatched types ‘const std::pair<_T1, _T2>’ and ‘int’
  106 |                 return get(1, 2, 3);
      |                        ~~~^~~~~~~~~
/usr/include/c++/13/bits/stl_pair.h:1069:5: note: candidate: ‘template<class _Tp, class _Up> constexpr _Tp&& std::get(pair<_T1, _T2>&&)’
 1069 |     get(pair<_Tp, _Up>&& __p) noexcept
      |     ^~~
/usr/include/c++/13/bits/stl_pair.h:1069:5: note:   template argument deduction/substitution failed:
answer.code:106:27: note:   mismatched types ‘std::pair<_T1, _T2>’ and ‘int’
  106 |                 return get(1, 2, 3);
      |                        ~~~^~~~~~~~~
/usr/include/c++/13/bits/stl_pair.h:1074:5: note: candidate: ‘template<class _Tp, class _Up> constexpr const _Tp&& std::get(const pair<_T1, _T2>&&)’
 1074 |     get(const pair<_Tp, _Up>&& __p) noexcept
      |     ^~~
/usr/include/c++/13/bits/stl_pair.h:1074:5: note:   template argument deduction/substitution failed:
answer.code:106:27: note:   mismatched types ‘const std::pair<_T1, _T2>’ and ‘int’
  106 |                 return get(1, 2, 3);
      |                        ~~~^~~~~~~~~
/usr/include/c++/13/bits/stl_pair.h:1079:5: note: candidate: ‘template<class _Tp, class _Up> constex...