QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#64170#91. Secret PermutationxiaoyaowudiCompile Error//C++201.3kb2022-11-24 11:01:252022-11-24 11:01:27

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-11-24 11:01:27]
  • 评测
  • [2022-11-24 11:01:25]
  • 提交

answer

#include "permutation.h"
#include <random>
#include <vector>
#include <algorithm>
#include <numeric>
#include <chrono>
#include <iostream>
constexpr int NN(310);
int idx[NN],res[NN],perm[NN];bool vis[NN];
bool dfs(int k,int n)
{
	if(k==n+1)
	{
		return std::abs(perm[idx[n]]-perm[idx[1]])==res[1];
	}
	if(perm[idx[k-1]]+res[k]<=n && !vis[perm[idx[k-1]]+res[k]])
	{
		vis[perm[idx[k]]=perm[idx[k-1]]+res[k]]=true;
		bool cap(dfs(k+1,n));
		if(cap) return true;
		vis[perm[idx[k]]]=false;
	}
	if(perm[idx[k-1]]-res[k]>=1 && !vis[perm[idx[k-1]]-res[k]])
	{
		vis[perm[idx[k]]=perm[idx[k-1]]-res[k]]=true;
		bool cap(dfs(k+1,n));
		if(cap) return true;
		vis[perm[idx[k]]]=false;
	}
	return false;
}
void solve(int N)
{
	int n(N);
	std::iota(idx+1,idx+n+1,1);
	std::mt19937 rnd(std::chrono::high_resolution_clock::now().time_since_epoch().count());
	std::shuffle(idx+1,idx+n+1,rnd);
	int tot(0);
	for(int i(1);i<=n;++i)
	{
		res[i]=query(idx+1);
		std::rotate(idx+1,idx+2,idx+n+1);
		tot+=res[i];
	}
	tot/=(n-1);
	for(int i(1);i<=n;++i) res[i]=tot-res[i];
	for(int i(1);i<=n;++i)
	{
		perm[idx[1]]=i;vis[i]=true;
		bool cap(dfs(2,n));
		if(cap)
		{
			// for(int i(1);i<=n;++i) std::cerr<<perm[i]<<" ";
			// std::cerr<<std::endl;
			answer(perm+1);
			return;
		}
		vis[i]=false;
	}
}

Details

answer.code: In function ‘void solve(int)’:
answer.code:41:33: error: could not convert ‘(((int*)(& idx)) + 4)’ from ‘int*’ to ‘std::vector<int>’
   41 |                 res[i]=query(idx+1);
      |                              ~~~^~
      |                                 |
      |                                 int*
answer.code:55:36: error: could not convert ‘(((int*)(& perm)) + 4)’ from ‘int*’ to ‘std::vector<int>’
   55 |                         answer(perm+1);
      |                                ~~~~^~
      |                                    |
      |                                    int*