QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#90429#5251. ConstellationsjakerWA 2ms3612kbC++142.6kb2023-03-23 01:49:262023-03-23 01:49:28

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-23 01:49:28]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3612kb
  • [2023-03-23 01:49:26]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = j;i <= k;++i)
#define repp(i,j,k) for(int i = j;i >= k;--i)
#define pb push_back
#define mp make_pair
#define fr first
#define se second
#define P pair<int,int>
#define Pp pair< pair<double, pair<int,int> > , pair<int,int> >
#define time tim
int n;
struct node{
	int x,y;
}e[2010];
long long Dis[2010][2010];
int dis[2010][2010],f[2010],sz[2010],tim[2010];
set< pair< pair<double, pair<int,int> > , pair<int,int> > >s;
int get(int x) {
	if(f[x] != x) {
		f[x] = get(f[x]);
		return f[x];
	}
	else return f[x];
}
void merge(int x,int y,int ttt) {
	int fx = get(x) , fy = get(y);
	f[fy] = fx;
	sz[fx] += sz[fy]; 
	time[fx] = ttt;
}
void output_P(Pp x) {
	printf("*%.10lf %d %d\n",x.fr.fr,x.se.fr,x.se.se);
}
void insert(int id,int t) {
	rep(i,1,n) Dis[id][i] = 0 , Dis[i][id] = 0;
	rep(i,1,n) if(get(i) == id) {
		rep(j,1,n) if(get(j) != id) {
			int idd = get(j);
			Dis[ min(id,idd) ][ max(id,idd) ] += dis[i][j];
		}	
	}
	rep(i,1,n) if(get(i) == i && i != id) {
		s.insert( mp(  mp(1.0*Dis[ min(i,id) ][ max(i,id) ]/(sz[i]*sz[id]) , 
							mp( max( time[i] , time[id] ) , min( time[i] , time[id] ) ) 
						 ) , 
					   mp( min(i,id) , max(i,id) ) 
					) );
	}
}
void output() {
	printf("\n");
	set<Pp>::iterator it;
	for(it = s.begin();it != s.end();it++)
		printf("*%.10lf %d %d %d %d\n",it->fr.fr,it->fr.se.fr,it->fr.se.se,it->se.fr,it->se.se);
}
int main() {
	freopen("1.in","r",stdin);
	scanf("%d",&n);
	rep(i,1,n) f[i] = i,sz[i] = 1,time[i] = i-n;
	rep(i,1,n) scanf("%d%d",&e[i].x,&e[i].y);
	rep(i,1,n) rep(j,i+1,n) {
		dis[i][j] = (e[i].x-e[j].x)*(e[i].x-e[j].x) + (e[i].y-e[j].y)*(e[i].y-e[j].y);
		dis[j][i] = dis[i][j];
		Dis[i][j] = dis[i][j];
		Dis[j][i] = dis[i][j];
		s.insert( mp( mp(dis[i][j], mp( time[j] , time[i] )  ) , mp(i,j) ) );
	}
	for(int ttt = 1;ttt < n;++ttt) {
		Pp x = (*s.begin());
		while( 1 ) {
			int id1 = get(x.se.fr) , id2 = get(x.se.se);
			if( x.se.fr != id1 || x.se.se != id2 ) {
				s.erase(s.begin()) , x = (*s.begin());
			}
			else if( ! (id1 == id2) && (1.0*Dis[min(id1,id2)][max(id1,id2)]/(sz[id1]*sz[id2]) == x.fr.fr) ) break;
			else s.erase(s.begin()) , x = (*s.begin());
		}
	/*	if(ttt == 1938)  {
		rep(i,1,n) printf("#%d %d\n",i,get(i)); printf("\n");
		printf("#%d %d %d %d %.10lf\n",x.se.fr,x.se.se,x.fr.se.fr,x.fr.se.se,x.fr.fr);
		}*/
		//printf("#%d %d %d %d %.10lf\n",x.se.fr,x.se.se,x.fr.se.fr,x.fr.se.se,x.fr.fr);
		merge( x.se.fr , x.se.se , ttt );
		int res = 0;
		rep(i,1,n) if( get(i) == x.se.fr ) res++;
		insert( x.se.fr , ttt );	
		printf("%d\n",res);
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 3612kb

input:

2
0 0
1 0

output:


result:

wrong answer 1st lines differ - expected: '2', found: ''