답안 #16735

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
16735 2015-09-12T08:36:59 Z suhgyuho_william 수족관 1 (KOI13_aqua1) C++
100 / 100
9 ms 3720 KB
#include <stdio.h>
#include <algorithm>
using namespace std;

int n;
int x[300002],y[300002];
bool check[300002];
long long leftwater;
double wtime;

int find_edge(int sx,int sy){
    int left,mid,right;

    left = 1;
    right = (n-2)/2;
    while(true){
        mid = (left+right)/2;
        if(sx == x[mid*2] && sy == y[mid*2]) break;
        if(sx < x[mid*2]) right = mid-1;
        else if(x[mid*2] < sx) left = mid+1;
        else{
            if(x[(mid-1)*2] == sx) return (mid-1)*2;
            else return (mid+1)*2;
        }
    }
    return mid*2;
}

double dfs(int s,int e,int hole){
    int i;
    int v,small;
    int shole,ehole;
    double watertime;

    if(s+1 == e) return 0;
    if(hole == 0){
        for(i=s+1; i<e; i+=2){
            if(y[i] == y[i+1]) leftwater += (long long)((long long)(x[i+1]-x[i])*(long long)(y[i]-y[s]));
        }

        return 0;
    }

    small = 999999999;
    for(i=s+1; i<e; i+=2){
        if(small > y[i]){
            small = y[i];
            v = i;
        }
    }
    shole = ehole = 0;
    for(i=s+1; i<v; i+=2){
        if(check[i]) shole++;
    }
    for(i=v+2; i<e; i+=2){
        if(check[i]) ehole++;
    }
    watertime = (double)((double)((double)(small-y[s])*(double)(x[e]-x[s]))/hole);
    y[s] = y[e] = small;
    return watertime+max(dfs(s,v,shole),dfs(v+1,e,ehole));
}

int main(void){
    int i,k;
    //freopen("input.txt","r",stdin);

    scanf("%d",&n);
    for(i=1; i<=n; i++){
        scanf("%d %d",&x[i],&y[i]);
    }
    scanf("%d",&k);
    for(i=1; i<=k; i++){
        scanf("%d %d %d %d",&x[0],&y[0],&x[n+1],&y[n+1]);
        check[find_edge(x[0],y[0])] = true;
    }
    wtime = leftwater = 0;

    wtime = dfs(1,n,k);

    //printf("%.2f\n%lld",wtime,leftwater);
    printf("%lld",leftwater);

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 3720 KB Output is correct
2 Correct 0 ms 3720 KB Output is correct
3 Correct 0 ms 3720 KB Output is correct
4 Correct 0 ms 3720 KB Output is correct
5 Correct 0 ms 3720 KB Output is correct
6 Correct 0 ms 3720 KB Output is correct
7 Correct 0 ms 3720 KB Output is correct
8 Correct 0 ms 3720 KB Output is correct
9 Correct 0 ms 3720 KB Output is correct
10 Correct 0 ms 3720 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 3720 KB Output is correct
2 Correct 0 ms 3720 KB Output is correct
3 Correct 0 ms 3720 KB Output is correct
4 Correct 0 ms 3720 KB Output is correct
5 Correct 0 ms 3720 KB Output is correct
6 Correct 0 ms 3720 KB Output is correct
7 Correct 0 ms 3720 KB Output is correct
8 Correct 0 ms 3720 KB Output is correct
9 Correct 0 ms 3720 KB Output is correct
10 Correct 0 ms 3720 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 3720 KB Output is correct
2 Correct 0 ms 3720 KB Output is correct
3 Correct 0 ms 3720 KB Output is correct
4 Correct 0 ms 3720 KB Output is correct
5 Correct 0 ms 3720 KB Output is correct
6 Correct 0 ms 3720 KB Output is correct
7 Correct 0 ms 3720 KB Output is correct
8 Correct 0 ms 3720 KB Output is correct
9 Correct 0 ms 3720 KB Output is correct
10 Correct 0 ms 3720 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 3720 KB Output is correct
2 Correct 0 ms 3720 KB Output is correct
3 Correct 0 ms 3720 KB Output is correct
4 Correct 0 ms 3720 KB Output is correct
5 Correct 2 ms 3720 KB Output is correct
6 Correct 9 ms 3720 KB Output is correct
7 Correct 6 ms 3720 KB Output is correct
8 Correct 6 ms 3720 KB Output is correct
9 Correct 0 ms 3720 KB Output is correct
10 Correct 0 ms 3720 KB Output is correct