답안 #13350

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
13350 2015-02-13T12:37:03 Z gs14004 수족관 1 (KOI13_aqua1) C++14
컴파일 오류
0 ms 0 KB
#include <cstdio>
#include <utility>
#include <map>
using namespace std;
typedef pair<int,int> pi;

int x[2505], y[2505], hole[2505], n;
map<pi,int> mp;

int h;

int f(int s, int e){
    if(s >= e) return 0;
    int pos = (int)(min_element(y+s,y+e)-y);
    int ret = 0;
    if(hole[pos] == 0) ret += (x[e] - x[s]) * (y[pos] - h);
    int ph = h;
    h = y[pos];
    ret += f(s,pos) + f(pos+1,e);
    h = ph;
    return ret;
}

int main(){
    scanf("%d",&n);
    n/=2;
    for (int i=0; i<n; i++) {
        int p,q;
        scanf("%d %d %d %d",&p,&q,&x[i],&y[i]);
        mp[pi(x[i],y[i])] = i;
    }
    int t;
    scanf("%d",&t);
    for (int i=0; i<t; i++) {
        int s,e,x,y;
        scanf("%d %d %d %d",&s,&e,&x,&y);
        hole[mp[pi(s,e)]] = 1;
    }
    printf("%d",f(0,n-1));
}

Compilation message

aqua1.cpp: In function ‘int f(int, int)’:
aqua1.cpp:14:40: error: ‘min_element’ was not declared in this scope
     int pos = (int)(min_element(y+s,y+e)-y);
                                        ^
aqua1.cpp: In function ‘int main()’:
aqua1.cpp:25:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
                   ^
aqua1.cpp:29:47: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d %d %d",&p,&q,&x[i],&y[i]);
                                               ^
aqua1.cpp:33:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&t);
                   ^
aqua1.cpp:36:41: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d %d %d",&s,&e,&x,&y);
                                         ^