QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#560972#8952. 解谜游戏zhouhuanyiCompile Error//C++232.4kb2024-09-12 19:14:342024-09-12 19:14:35

Judging History

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

  • [2024-09-12 19:14:35]
  • 评测
  • [2024-09-12 19:14:34]
  • 提交

answer

#include "puzzle.h"
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<random>
#define N 1000
using namespace std;
mt19937 RAND(random_device{}());
struct reads
{
	int x,y;
};
vector<reads>p[N+1];
int tn,n,length,tong[N+1],rd[N+1];
bool used[N+1];
vector<int>E[N+1];
int get(int x)
{
	if (x>tn) x-=tn;
	if (x<1) x+=tn;
	return x;
}
void add_edge(int x,int y)
{
	E[x].push_back(y),E[y].push_back(x);
	return;
}
void solve(vector<reads>sp,int res)
{
	if (!res) return;
	if (sp.size()==1)
	{
		for (int i=0;i<sp.size();++i) add_edge(sp[i].x,sp[i].y);
		return;
	}
	vector<reads>A;
	vector<reads>B;
	int mid=sp.size()>>1,d;
	vector<int>tp(n);
	for (int i=1;i<=n;++i) tp[i-1]=rd[i];
	for (int i=0;i<mid;++i) A.push_back(sp[i]),tp[sp[i].x-1]=rd[sp[i].y],tp[sp[i].y-1]=rd[sp[i].x];
	for (int i=mid;i<sp.size();++i) B.push_back(sp[i]);
	d=query(tp),solve(A,d),solve(B,res-d);
	return;
}
void dfs(int x)
{
	used[x]=1,tong[++length]=x;
	for (int i=0;i<E[x].size();++i)
		if (!used[E[x][i]])
			dfs(E[x][i]);
	return;
}
void play(int sn)
{
	n=sn;
	vector<reads>tp;
	vector<int>sp(n);
	vector<int>ans(n);
	for (int i=1;i<=n;++i) sp[i-1]=i;
	while (1)
	{
		shuffle(sp.begin(),sp.end(),RAND);
		if (!count(sp)) break;
	}
	for (int i=1;i<=n;++i) rd[i]=sp[i-1];
	if (!(n&1))
	{
		tn=n-1;
		for (int i=1;i<=n-1;++i)
		{
			p[i].push_back((reads){i,n});
			for (int j=1;j<=(n>>1)-1;++j) p[i].push_back((reads){get(i-j),get(i+j)});
		}
	}
	else
	{
		tn=n;
		for (int i=1;i<=n;++i)
			for (int j=1;j<=(n>>1);++j)
				p[i].push_back((reads){get(i-j),get(i+j)});
	}
	for (int i=1;i<=n;++i)
		if (!p[i].empty())
		{
			tp.clear();
			for (int j=0;j<p[i].size();++j)
				if (E[p[i][j].x].size()<=1&&E[p[i][j].y].size()<=1)
					tp.push_back(p[i][j]);
			if (!tp.empty())
			{
				for (int j=1;j<=n;++j) sp[j-1]=rd[j];
				for (int j=0;j<tp.size();++j) sp[tp[j].x-1]=rd[tp[j].y],sp[tp[j].y-1]=rd[tp[j].x];
				solve(tp,count(sp));
			}
		}
	for (int i=1;i<=n;++i)
		if (!used[i])
		{
			length=0,dfs(i);
			for (int j=1;j<=n;++j) sp[j-1]=rd[j];
			for (int j=1;j<=length;++j) sp[tong[j]-1]=rd[tong[j%length+1]];
			if (count(sp))
			{
				for (int j=1;j<=length;++j) ans[tong[j]-1]=rd[tong[j%length+1]];
			}
			else
			{
				for (int j=1;j<=length;++j) ans[tong[j%length+1]-1]=rd[tong[j]];
			}
		}
	check(ans);
	return;
}

Details

implementer.cpp: In constructor ‘a068d5f76423877cf1d63d2b66a308e7::Puzzle::Puzzle()’:
implementer.cpp:45:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   45 |                         scanf("%d%d%d",&id,&n,&seed);
      |                         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
answer.code: In function ‘void play(int)’:
answer.code:65:27: error: no matching function for call to ‘count(std::vector<int>&)’
   65 |                 if (!count(sp)) break;
      |                      ~~~~~^~~~
In file included from /usr/include/c++/13/algorithm:61,
                 from answer.code:4:
/usr/include/c++/13/bits/stl_algo.h:4072:5: note: candidate: ‘template<class _IIter, class _Tp> constexpr typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)’
 4072 |     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
      |     ^~~~~
/usr/include/c++/13/bits/stl_algo.h:4072:5: note:   template argument deduction/substitution failed:
answer.code:65:27: note:   candidate expects 3 arguments, 1 provided
   65 |                 if (!count(sp)) break;
      |                      ~~~~~^~~~
In file included from /usr/include/c++/13/algorithm:73:
/usr/include/c++/13/pstl/glue_algorithm_defs.h:101:1: note: candidate: ‘template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)’
  101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~~
/usr/include/c++/13/pstl/glue_algorithm_defs.h:101:1: note:   template argument deduction/substitution failed:
answer.code:65:27: note:   candidate expects 4 arguments, 1 provided
   65 |                 if (!count(sp)) break;
      |                      ~~~~~^~~~
answer.code:95:47: error: no matching function for call to ‘count(std::vector<int>&)’
   95 |                                 solve(tp,count(sp));
      |                                          ~~~~~^~~~
/usr/include/c++/13/bits/stl_algo.h:4072:5: note: candidate: ‘template<class _IIter, class _Tp> constexpr typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)’
 4072 |     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
      |     ^~~~~
/usr/include/c++/13/bits/stl_algo.h:4072:5: note:   template argument deduction/substitution failed:
answer.code:95:47: note:   candidate expects 3 arguments, 1 provided
   95 |                                 solve(tp,count(sp));
      |                                          ~~~~~^~~~
/usr/include/c++/13/pstl/glue_algorithm_defs.h:101:1: note: candidate: ‘template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)’
  101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~~
/usr/include/c++/13/pstl/glue_algorithm_defs.h:101:1: note:   template argument deduction/substitution failed:
answer.code:95:47: note:   candidate expects 4 arguments, 1 provided
   95 |                                 solve(tp,count(sp));
      |                                          ~~~~~^~~~
answer.code:104:34: error: no matching function for call to ‘count(std::vector<int>&)’
  104 |                         if (count(sp))
      |                             ~~~~~^~~~
/usr/include/c++/13/bits/stl_algo.h:4072:5: note: candidate: ‘template<class _IIter, class _Tp> constexpr typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)’
 4072 |     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
      |     ^~~~~
/usr/include/c++/13/bits/stl_algo.h:4072:5: note:   template argument deduction/substitution failed:
answer.code:104:34: note:   candidate expects 3 arguments, 1 provided
  104 |                         if (count(sp))
      |                             ~~~~~^~~~
/usr/include/c++/13/pstl/glue_algorithm_defs.h:101:1: note: candidate: ‘template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)’
  101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~~
/usr/include/c++/13/pstl/glue_algorithm_defs.h:101:1: note:   template argument deduction/substitution failed:
answer.code:104:34: note:   can...