Submission #16764

#TimeUsernameProblemLanguageResultExecution timeMemory
16764suhgyuho_william수족관 2 (KOI13_aqua2)C++98
0 / 100
204 ms8700 KiB
#include <stdio.h> #include <algorithm> using namespace std; int n,k; struct data{ int x,y; }a[300002]; struct data2{ int first,second; bool operator()(data2 x,data2 y){ return (x.first > y.first); } }ta[150002]; int find_hole(int ix,int iy){ int s,mid,e; s = 1; e = (n/2)-1; while(true){ mid = (s+e)/2; if(a[mid*2].x == ix && a[mid*2].y == iy) return mid*2; if(a[mid*2].x > ix) e = mid-1; else s = mid+1; } } int left_node[150002],right_node[150002]; int left_y[150002],right_y[150002]; int hole[150002]; void Input(){ int i,ix,iy; //freopen("input.txt","r",stdin); scanf("%d",&n); for(i=1; i<=n; i++){ scanf("%d %d",&a[i].x,&a[i].y); } scanf("%d",&k); for(i=1; i<=k; i++){ scanf("%d %d",&ix,&iy); hole[find_hole(ix,iy)/2]++; scanf("%d %d",&ix,&iy); } for(i=1; i<n/2; i++) ta[i].first = a[i*2].y; for(i=1; i<n/2; i++) ta[i].second = i*2; sort(ta+1,ta+(n/2),data2()); } void set_tree(){ int i,index; for(i=1; i<n/2; i++){ left_node[i] = i-1; right_node[i] = i+1; left_y[i] = a[(i*2)-1].y; right_y[i] = a[(i*2)+2].y; } } double watertime[150002]; double anstime; long long leftwater; long long water; void aqua(){ int i,index; for(i=1; i<n/2; i++){ index = ta[i].second/2; water = (long long)(a[right_node[index]*2].x - a[(left_node[index]*2)+1].x); if(left_y[index] >= right_y[index]){ water *= (long long)(a[index*2].y-a[left_node[index]*2].y); hole[left_node[index]] += hole[index]; if(hole[index] == 0) leftwater += water; else watertime[index] += ((double)water / (double)hole[index]); watertime[left_node[index]] = max(watertime[left_node[index]],watertime[index]); right_node[left_node[index]] = right_node[index]; right_y[left_node[index]] = right_y[index]; }else{ water *= (long long)(a[index*2].y-a[right_node[index]*2].y); hole[right_node[index]] += hole[index]; if(hole[index] == 0) leftwater += water; else watertime[index] += ((double)water / (double)hole[index]); watertime[right_node[index]] = max(watertime[right_node[index]],watertime[index]); left_node[right_node[index]] = left_node[index]; left_y[right_node[index]] = left_y[index]; } } } void print(){ for(int i=1; i<n/2; i++) if(anstime < watertime[i]) anstime = watertime[i]; printf("%.2f\n",anstime); printf("%lld",leftwater); } int main(void){ Input(); set_tree(); aqua(); print(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...