QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#464596#5029. 在路上MEKHANECompile Error//C++141.2kb2024-07-06 12:28:192024-07-06 12:28:21

Judging History

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

  • [2024-07-06 12:28:21]
  • 评测
  • [2024-07-06 12:28:19]
  • 提交

answer

#include<bits/stdc++.h>
#include "path.h"
#define rep(i,j,k) for(int i=j;i<=k;i++)
using namespace std;
const int L=1000;
int n,min1,min2,rt,in[L],siz[L],mp[L][L],id[50*L];
vector<int> v[L];
queue<int> que;
void dfs(int x){
    siz[x]=1; int max1=0;
    for(auto dq:v[x]) dfs(dq),siz[x]+=siz[dq],max1=max(max1,siz[dq]);
    max1=max(max1,n-siz[x]);
    if(max1<min1) min1=max1,min2=x;
}
int centroid(int id,int N,int M){
    if(id==3||id==5){
        rep(i,1,N) id[i]=i;
		int x=1,y=2;
        rep(i,3,N){
			int dq=ask(x,y,i);
			if(dq==x) x=i; else if(dq==y) y=i;
		}rt=x;
		nth_element(id+1,id+(N+1)/2,id+1+N,cmp);
		return id[(N+1)/2];
	}else{
        n=N;
        rep(i,1,N){siz[i]=in[i]=0,v[i].clear(); rep(j,1,N) mp[i][j]=0;}
        rep(i,2,N) rep(j,i+1,N){
            int res=ask(1,i,j);
            if(res==i) mp[i][j]=1,in[j]++;
            else if(res==j) mp[j][i]=1,in[i]++;
        }
        rep(i,2,N) if(!in[i]) v[1].push_back(i),que.push(i);
        while(!que.empty()){
            int x=que.front(); que.pop();
            rep(i,1,N) if(mp[x][i]) if(!(--in[i])) v[x].push_back(i),que.push(i);
        }min1=1e9,min2=0,dfs(1); return min2;
    }
}

詳細信息

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:17:22: error: invalid types ‘int[int]’ for array subscript
   17 |         rep(i,1,N) id[i]=i;
      |                      ^
answer.code:23:52: error: ‘cmp’ was not declared in this scope; did you mean ‘mp’?
   23 |                 nth_element(id+1,id+(N+1)/2,id+1+N,cmp);
      |                                                    ^~~
      |                                                    mp
answer.code:24:26: error: invalid types ‘int[int]’ for array subscript
   24 |                 return id[(N+1)/2];
      |                          ^