Submission #2669353


Source Code Expand

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-13;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
int x[110];
int y[110];
int p[110];
double g[20][20];
double t[1<<15];
double dp[1<<15];
int UF[20];
int FIND(int a){
	if(UF[a]<0)return a;
	return UF[a]=FIND(UF[a]);
}
void UNION(int a,int b){
	a=FIND(a);b=FIND(b);if(a==b)return;UF[a]+=UF[b];UF[b]=a;
}
pair<double,pair<int,int> > edge[400];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%d%d%d",x+i,y+i,p+i);
	}
	for(int i=0;i<a;i++){
		for(int j=0;j<a;j++){
			g[i][j]=sqrt((long long)(x[i]-x[j])*(x[i]-x[j])+(long long)(y[i]-y[j])*(y[i]-y[j]));
		}
	}
	for(int i=1;i<(1<<a);i++){
		double tmp=0;
		int cnt=0;
		for(int j=0;j<a;j++){
			if(i&(1<<j)){
				cnt++;
				tmp+=p[j];
			}
		}
		for(int j=0;j<a;j++){UF[j]=-1;}
		int sz=0;
		for(int j=0;j<a;j++){
			for(int k=j+1;k<a;k++){
				if(i&(1<<j)){
					if(i&(1<<k)){
						edge[sz++]=make_pair(g[j][k],make_pair(j,k));
					}
				}
			}
		}
		std::sort(edge,edge+sz);
		for(int j=0;j<sz;j++){
			if(FIND(edge[j].second.first)!=FIND(edge[j].second.second)){
				tmp-=edge[j].first;
				UNION(edge[j].second.first,edge[j].second.second);
			}
		}
		t[i]=tmp/cnt;
	}
	dp[0]=mod;
	for(int i=1;i<(1<<a);i++){
		int j=i;
		while(j){
			dp[i]=max(dp[i],min(dp[i-j],t[j]));
			j=((j-1)&i);
		}
	}
	printf("%.12f\n",dp[(1<<a)-1]);
}

Submission Info

Submission Time
Task E - Water Distribution
User tozangezan
Language C++14 (GCC 5.4.1)
Score 1000
Code Size 1914 Byte
Status AC
Exec Time 103 ms
Memory 640 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:42:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  int a;scanf("%d",&a);
                      ^
./Main.cpp:44:30: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%d",x+i,y+i,p+i);
                              ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 1000 / 1000
Status
AC × 2
AC × 46
Set Name Test Cases
Sample example0.txt, example1.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt, 031.txt, 032.txt, 033.txt, 034.txt, 035.txt, 036.txt, 037.txt, 038.txt, 039.txt, 040.txt, 041.txt, 042.txt, 043.txt, example0.txt, example1.txt
Case Name Status Exec Time Memory
000.txt AC 101 ms 640 KB
001.txt AC 102 ms 640 KB
002.txt AC 101 ms 640 KB
003.txt AC 101 ms 640 KB
004.txt AC 103 ms 640 KB
005.txt AC 99 ms 640 KB
006.txt AC 103 ms 640 KB
007.txt AC 98 ms 640 KB
008.txt AC 101 ms 640 KB
009.txt AC 101 ms 640 KB
010.txt AC 103 ms 640 KB
011.txt AC 102 ms 640 KB
012.txt AC 102 ms 640 KB
013.txt AC 99 ms 640 KB
014.txt AC 102 ms 640 KB
015.txt AC 103 ms 640 KB
016.txt AC 98 ms 640 KB
017.txt AC 102 ms 640 KB
018.txt AC 100 ms 640 KB
019.txt AC 98 ms 640 KB
020.txt AC 98 ms 640 KB
021.txt AC 101 ms 640 KB
022.txt AC 100 ms 640 KB
023.txt AC 97 ms 640 KB
024.txt AC 100 ms 640 KB
025.txt AC 95 ms 640 KB
026.txt AC 98 ms 640 KB
027.txt AC 96 ms 640 KB
028.txt AC 95 ms 640 KB
029.txt AC 95 ms 640 KB
030.txt AC 94 ms 640 KB
031.txt AC 96 ms 640 KB
032.txt AC 94 ms 640 KB
033.txt AC 94 ms 640 KB
034.txt AC 93 ms 640 KB
035.txt AC 93 ms 640 KB
036.txt AC 93 ms 640 KB
037.txt AC 94 ms 640 KB
038.txt AC 94 ms 640 KB
039.txt AC 93 ms 640 KB
040.txt AC 1 ms 128 KB
041.txt AC 1 ms 128 KB
042.txt AC 1 ms 128 KB
043.txt AC 1 ms 128 KB
example0.txt AC 1 ms 128 KB
example1.txt AC 100 ms 640 KB