QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#464597#5029. 在路上MEKHANECompile Error//C++141.2kb2024-07-06 12:32:182024-07-06 12:32:18

Judging History

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

  • [2024-07-06 12:32:18]
  • 评测
  • [2024-07-06 12:32:18]
  • 提交

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;
}
bool cmp(int x,int y){return ask(rt,x,y)==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;
    }
}

Details

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:18:22: error: invalid types ‘int[int]’ for array subscript
   18 |         rep(i,1,N) id[i]=i;
      |                      ^
answer.code:25:26: error: invalid types ‘int[int]’ for array subscript
   25 |                 return id[(N+1)/2];
      |                          ^
In file included from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from answer.code:1:
/usr/include/c++/13/bits/stl_algobase.h: In instantiation of ‘void std::iter_swap(_ForwardIterator1, _ForwardIterator2) [with _ForwardIterator1 = int; _ForwardIterator2 = int]’:
/usr/include/c++/13/bits/stl_algo.h:1967:22:   required from ‘void std::__introselect(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = int; _Size = int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(int, int)>]’
/usr/include/c++/13/bits/stl_algo.h:4829:25:   required from ‘void std::nth_element(_RAIter, _RAIter, _RAIter, _Compare) [with _RAIter = int; _Compare = bool (*)(int, int)]’
answer.code:24:14:   required from here
/usr/include/c++/13/bits/stl_algobase.h:185:12: error: invalid type argument of unary ‘*’ (have ‘int’)
  185 |       swap(*__a, *__b);
      |            ^~~~
/usr/include/c++/13/bits/stl_algobase.h:185:18: error: invalid type argument of unary ‘*’ (have ‘int’)
  185 |       swap(*__a, *__b);
      |                  ^~~~
In file included from /usr/include/c++/13/algorithm:61:
/usr/include/c++/13/bits/stl_algo.h: In instantiation of ‘void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(int, int)>]’:
/usr/include/c++/13/bits/stl_algo.h:1978:28:   required from ‘void std::__introselect(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = int; _Size = int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(int, int)>]’
/usr/include/c++/13/bits/stl_algo.h:4829:25:   required from ‘void std::nth_element(_RAIter, _RAIter, _RAIter, _Compare) [with _RAIter = int; _Compare = bool (*)(int, int)]’
answer.code:24:14:   required from here
/usr/include/c++/13/bits/stl_algo.h:1822:17: error: no type named ‘value_type’ in ‘struct std::iterator_traits<int>’
 1822 |                 __val = _GLIBCXX_MOVE(*__i);
      |                 ^~~~~
/usr/include/c++/13/bits/stl_algo.h:1824:15: error: invalid type argument of unary ‘*’ (have ‘int’)
 1824 |               *__first = _GLIBCXX_MOVE(__val);
      |               ^~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:1822:17: error: no type named ‘value_type’ in ‘struct std::iterator_traits<int>’
 1822 |                 __val = _GLIBCXX_MOVE(*__i);
      |                 ^~~~~
In file included from /usr/include/c++/13/bits/stl_algo.h:61:
/usr/include/c++/13/bits/stl_heap.h: In instantiation of ‘void std::__make_heap(_RandomAccessIterator, _RandomAccessIterator, _Compare&) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(int, int)>]’:
/usr/include/c++/13/bits/stl_algo.h:1635:23:   required from ‘void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(int, int)>]’
/usr/include/c++/13/bits/stl_algo.h:1965:26:   required from ‘void std::__introselect(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = int; _Size = int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(int, int)>]’
/usr/include/c++/13/bits/stl_algo.h:4829:25:   required from ‘void std::nth_element(_RAIter, _RAIter, _RAIter, _Compare) [with _RAIter = int; _Compare = bool (*)(int, int)]’
answer.code:24:14:   required from here
/usr/include/c++/13/bits/stl_heap.h:344:11: error: no type named ‘value_type’ in ‘struct std::iterator_traits<int>’
  344 |           _ValueType;
      |           ^~~~~~~~~~
/usr/include/c++/13/bits/stl_heap.h:346:11: error: no type named ‘difference_type’ in ‘struct std::iterator_traits<int>’
  346 |           _DistanceType;
      |           ^~~~~~~~~~~~~
In file included from /usr/include/c++/13/bits/stl_algobase.h:71:
/usr/include/c++/13/bits/predefined_ops.h: In instantiation of ‘constexpr bool __gnu_cxx::__ops::_Iter_comp_iter<_Compare>::operator()(_Iterator1, _Iterator2) [with _Iterator1 = int; _Iterator2 = int; _Compare = bool (*)(int, int)]’:
/usr/include/c++/13/bits/stl_algo.h:1637:1...