QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#860090#9678. 网友小 Z 的树lesunhan2022Compile Error//C++141.1kb2025-01-18 10:17:292025-01-18 10:17:46

Judging History

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

  • [2025-01-18 10:17:46]
  • 评测
  • [2025-01-18 10:17:29]
  • 提交

answer

#include"diameter.h"
#include<bits/stdc++.h>
using namespace std;
pair<int,int> find_diameter(int task_id,int n){
	if(n==1) return {1,1};
	if(n==2) return {1,2};
	if(n==3){
		if(in(1,2,3)) return {2,3};
		if(in(2,1,3)) return {1,3};
		return {1,2};
	}
	const auto find([&](int x,int y)->tuple<tuple<int,int>,tuple<int,int>> {
		tuple<int,int> min(1000000000,0),max(-1000000000,0);
		for(int i=1;i<=n;i++){
			if(i==x||i==y) continue;
			tuple<int,int> tmp(query(x,y,i),i);
			min=min(min,tmp);
			max=max(max,tmp);
		}
		return {min,max};
	});
	const auto dis([&](const int &x,const int &y)->int{
		return get<0>(get<0>(find(x,y)));
	});
	int a{get<1>(get<1>(find(1,2)))};
	int b{get<1>(get<1>(find(1,a)))};
	auto [r0,r1](find(a,b));
	auto [d0,x](r0);d0>>=1;
	auto [s,c](r1);
	if(x==c) return {a,b};
	int d1{},d2{};
	if(in(x,a,b)){
		if(in(x,a,c)){
			d1=query(x,a,c)>>1;
			d2=s-d0-d1;
		}
		else{
			d2=query(x,b,c)>>1;
			d1=s-d0-d2;
		}
	}
	else{
		if(in(b,a,c)) return {a,c};
		else return {b,c};
	}
	if(d0>=d1&&d0>=d2) return {a,b};
	if(d1>=d2) return {a,c};
	return {b,c};
}

Details

answer.code: In lambda function:
answer.code:17:32: error: no match for call to ‘(std::tuple<int, int>) (std::tuple<int, int>&, std::tuple<int, int>&)’
   17 |                         min=min(min,tmp);
      |                             ~~~^~~~~~~~~
answer.code:18:32: error: no match for call to ‘(std::tuple<int, int>) (std::tuple<int, int>&, std::tuple<int, int>&)’
   18 |                         max=max(max,tmp);
      |                             ~~~^~~~~~~~~
answer.code: In function ‘std::pair<int, int> find_diameter(int, int)’:
answer.code:27:14: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   27 |         auto [r0,r1](find(a,b));
      |              ^
answer.code:28:14: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   28 |         auto [d0,x](r0);d0>>=1;
      |              ^
answer.code:29:14: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   29 |         auto [s,c](r1);
      |              ^