QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#225916#7584. Support or NotPhantomThresholdCompile Error//C++143.1kb2023-10-25 11:44:272023-10-25 11:44:27

Judging History

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

  • [2023-10-25 11:44:27]
  • 评测
  • [2023-10-25 11:44:27]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

ll ceilsq(ll x){
	if (x==0) return 0;
	ll sz=sqrtl(x);
	for (;(sz)*(sz)<x;) sz++;
	for (;(sz-1)*(sz-1)>=x;) sz--;
	return sz; 	
}

typedef long long db;

struct point{
	db x,y,z;
	point operator + (const point &k1){return (point){x+k1.x,y+k1.y,z+k1.z};}
	point operator - (const point &k1){return (point){x-k1.x,y-k1.y,z-k1.z};}
	db abs(){return ceilsq(x*x+y*y+z*z);}
	db abs2(){return x*x+y*y+z*z;}
	db dis(point k){return ((*this)-k).abs();}
	db dis2(point k){return ((*this)-k).abs2();}
};

struct circle{
	point o;
	db r;
};

const int maxn=100000;
const int base=1000001;
int n,k;
circle a[maxn+50];

int cnt=0;
vector<db> ans;

ll getid(ll x,ll y,ll z){
	return (x<<40)|(y<<20)|(z);
}
void check(db mid,bool flag=0){
//	cerr << "-----------" << endl;
//	cerr << "check : " << mid << endl;
	cnt=0;
	
	db pre2R=2e9;
	unordered_map<ll,vector<int>> dict;
	for (int i=1;i<=n;i++){
		if (a[i].r*4+mid*2<pre2R){
			pre2R=a[i].r*2+mid;
			unordered_map<ll,vector<int>> nxtdict;
			for (int j=1;j<i;j++){
				ll nowx=a[j].o.x/pre2R;
				ll nowy=a[j].o.y/pre2R;
				ll nowz=a[j].o.z/pre2R;
				ll id=getid(nowx,nowy,nowz);
				nxtdict[id].push_back(j);
			//	cerr << "reconstruct : " << j << " " << nowx << " " << nowy << " " << nowz << endl;
			}
			nxtdict.swap(dict);
		}
		
		ll nowx=a[i].o.x/pre2R;
		ll nowy=a[i].o.y/pre2R;
		ll nowz=a[i].o.z/pre2R;
		/*
		cerr << "nowi : " << i << " " << nowx << " " << nowy << " " << nowz << endl;
		for (auto &[id,v]:dict){
			cerr << "id : " << bitset<60>(id) << endl;
			cerr << "v : ";
			for (auto e:v) cerr << e << " ";
			cerr << endl;	
		}
		*/
		
		for (ll dx=-1;dx<=1;dx++){
			if (nowx+dx<0) continue;
			for (ll dy=-1;dy<=1;dy++){
				if (nowy+dy<0) continue;
				for (ll dz=-1;dz<=1;dz++){
					if (nowz+dz<0) continue;
					ll id=getid(nowx+dx,nowy+dy,nowz+dz);
					if (dict.contains(id)){
						auto &v=dict[id];
						for (auto j:v){
							db d=a[i].o.dis(a[j].o)-a[i].r-a[j].r;
							
							d=max(d,(db)0);
							
							if (d<=mid){
								if (flag) ans.push_back(d);
								cnt++;
								if (cnt==k) return;	
							}
							
						}
					}
				}	
			}	
		}
		
		ll id=getid(nowx,nowy,nowz);
		dict[id].emplace_back(i);
	}
}

void solve(){
	cin >> n >> k;
	for (int i=1;i<=n;i++)
		cin >> a[i].o.x >> a[i].o.y >> a[i].o.z >> a[i].r;
	sort(a+1,a+n+1,
		[&](const circle &A,const circle &B){
			return A.r>B.r;	
		}
	);	
	db l=0,r=1e7;
	while (l<r){
		db mid=(l+r)/2;
		check(mid,0);
		
	//	cerr << "l,r : " << l << " " << r << "\n";
	//	cerr << cnt << "\n";
		
		if (cnt==k) r=mid;
		else l=mid+1;
	}
	if (l>1){
		check(l-1,1);
		while (cnt!=k){
			ans.push_back(l);
			cnt++;
		}
	}
	else{
		ans.clear();
		for (int i=1;i<=k;i++) ans.push_back(0);
	}
	sort(ans.begin(),ans.end());
	for (auto e:ans) cout << e << "\n";
	ans.clear();
}

int main(){
	ios_base::sync_with_stdio(false);
	int Tcase=3;
	cin >> Tcase;
	for (;Tcase--;){
		solve();
	}
	return 0;	
}

详细

answer.code: In function ‘void check(db, bool)’:
answer.code:84:50: error: ‘class std::unordered_map<long long int, std::vector<int> >’ has no member named ‘contains’
   84 |                                         if (dict.contains(id)){
      |                                                  ^~~~~~~~