Submission #32183

# Submission time Handle Problem Language Result Execution time Memory
32183 2017-10-03T10:35:12 Z dongwon0427 Aliens (IOI16_aliens) C++11
4 / 100
9 ms 5536 KB
#include "aliens.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,ld> pil;
struct _tuple {
    int x,y;
};
_tuple A[100005],B[100005];
int n;
ld dp[100005];
int gaesu[100005];
pil CHT(ld c) {
    gaesu[0]=0;
    for(int i=1;i<=n;i++) {
        dp[i] = (ld)(A[i].y-A[1].x+1)*(ld)(A[i].y-A[1].x+1)-c;
        int minidx = 0;
        for(int j=1;j<i;j++) {
            if( dp[i] > dp[j] + (ld)(A[i].y-A[j+1].x+1)*(ld)(A[i].y-A[j+1].x+1) - (ld)max(0,-A[j+1].x+A[j].y+1)*(ld)max(0,-A[j+1].x+A[j].y+1) - c ) {
                minidx = j;
                dp[i] = dp[j] + (ld)(A[i].y-A[j+1].x+1)*(ld)(A[i].y-A[j+1].x+1) - (ld)max(0,-A[j+1].x+A[j].y+1)*(ld)max(0,-A[j+1].x+A[j].y+1) - c;
            }
        }
        gaesu[i] = gaesu[minidx]+1;
    }
    //cout<<c<<" : "<<dp[n]<<' '<<gaesu[n]<<endl;
    return pil(gaesu[n],dp[n]);
}
ll take_photos(int N, int m, int k, std::vector<int> r, std::vector<int> c) {
    for(int i=0;i<N;i++) {
        B[i].x=r[i];
        B[i].y=c[i];
        if(B[i].x > B[i].y) swap(B[i].x,B[i].y);
    }
    sort(B,B+N,[](_tuple a,_tuple b){return a.x>b.x;});
    for(int i=0;i<N;i++) {
        while(n!=0 && A[n].y <= B[i].y) {
            n--;
        }
        A[++n] = B[i];
    }
    reverse(A+1,A+1+n);
    if(k>n) k = n;
    ll bs = -(ll)m*(ll)m-1ll, be = 0;
    int lft=1,rht=n;
    ll L=(ll)m*(ll)m,R=(ll)m*(ll)m;
    while(bs<=be) {
        ll bm = (bs+be)/2;
        //printf("%d\n",bm);
        ld gi = (ld)bm + (ld)0.5;
        pil tmp = CHT(gi);
        if(tmp.first==k) {
            return (long long)(tmp.second + gi*(ld)(k));
        }
        if(tmp.first > k) {
            be=bm-1;
            if(rht >= tmp.first) {
                rht = tmp.first;
                R = (ll)(tmp.second + gi*(ld)(k));
            }
        } else {
            bs=bm+1;
            if(lft <= tmp.first) {
                lft = tmp.first;
                R = (ll)(tmp.second + gi*(ld)(k));
            }
        }
    }
    /*for(ll i=bs;i<=be;i++) {
        CHT((ld)i+(ld)0.5);
    }*/
    return 0;
    //return (L*(ll)(rht-k) + R*(ll)(k-lft)) / (ll)(-lft+rht);
}

Compilation message

aliens.cpp: In function 'll take_photos(int, int, int, std::vector<int>, std::vector<int>)':
aliens.cpp:47:8: warning: unused variable 'L' [-Wunused-variable]
     ll L=(ll)m*(ll)m,R=(ll)m*(ll)m;
        ^
aliens.cpp:47:22: warning: variable 'R' set but not used [-Wunused-but-set-variable]
     ll L=(ll)m*(ll)m,R=(ll)m*(ll)m;
                      ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5536 KB Correct answer: answer = 4
2 Correct 0 ms 5536 KB Correct answer: answer = 4
3 Correct 0 ms 5536 KB Correct answer: answer = 4
4 Correct 0 ms 5536 KB Correct answer: answer = 12
5 Correct 0 ms 5536 KB Correct answer: answer = 52
6 Correct 0 ms 5536 KB Correct answer: answer = 210
7 Correct 0 ms 5536 KB Correct answer: answer = 88
8 Correct 0 ms 5536 KB Correct answer: answer = 7696
9 Correct 0 ms 5536 KB Correct answer: answer = 1
10 Correct 0 ms 5536 KB Correct answer: answer = 2374
11 Correct 0 ms 5536 KB Correct answer: answer = 9502
12 Correct 0 ms 5536 KB Correct answer: answer = 49
13 Correct 0 ms 5536 KB Correct answer: answer = 151
14 Correct 0 ms 5536 KB Correct answer: answer = 7550
15 Correct 0 ms 5536 KB Correct answer: answer = 7220
16 Correct 0 ms 5536 KB Correct answer: answer = 7550
17 Correct 0 ms 5536 KB Correct answer: answer = 10000
18 Correct 0 ms 5536 KB Correct answer: answer = 10000
19 Correct 0 ms 5536 KB Correct answer: answer = 624
20 Correct 0 ms 5536 KB Correct answer: answer = 10000
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5536 KB Correct answer: answer = 1
2 Correct 0 ms 5536 KB Correct answer: answer = 4
3 Correct 0 ms 5536 KB Correct answer: answer = 1
4 Correct 0 ms 5536 KB Correct answer: answer = 5
5 Correct 0 ms 5536 KB Correct answer: answer = 41
6 Correct 0 ms 5536 KB Correct answer: answer = 71923
7 Correct 0 ms 5536 KB Correct answer: answer = 77137
8 Incorrect 9 ms 5536 KB Wrong answer: output = 0, expected = 764
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5536 KB Correct answer: answer = 4
2 Correct 0 ms 5536 KB Correct answer: answer = 4
3 Correct 0 ms 5536 KB Correct answer: answer = 4
4 Correct 0 ms 5536 KB Correct answer: answer = 12
5 Correct 0 ms 5536 KB Correct answer: answer = 52
6 Correct 0 ms 5536 KB Correct answer: answer = 210
7 Correct 0 ms 5536 KB Correct answer: answer = 88
8 Correct 0 ms 5536 KB Correct answer: answer = 7696
9 Correct 0 ms 5536 KB Correct answer: answer = 1
10 Correct 0 ms 5536 KB Correct answer: answer = 2374
11 Correct 0 ms 5536 KB Correct answer: answer = 9502
12 Correct 0 ms 5536 KB Correct answer: answer = 49
13 Correct 0 ms 5536 KB Correct answer: answer = 151
14 Correct 0 ms 5536 KB Correct answer: answer = 7550
15 Correct 0 ms 5536 KB Correct answer: answer = 7220
16 Correct 0 ms 5536 KB Correct answer: answer = 7550
17 Correct 0 ms 5536 KB Correct answer: answer = 10000
18 Correct 0 ms 5536 KB Correct answer: answer = 10000
19 Correct 0 ms 5536 KB Correct answer: answer = 624
20 Correct 0 ms 5536 KB Correct answer: answer = 10000
21 Correct 0 ms 5536 KB Correct answer: answer = 1
22 Correct 0 ms 5536 KB Correct answer: answer = 4
23 Correct 0 ms 5536 KB Correct answer: answer = 1
24 Correct 0 ms 5536 KB Correct answer: answer = 5
25 Correct 0 ms 5536 KB Correct answer: answer = 41
26 Correct 0 ms 5536 KB Correct answer: answer = 71923
27 Correct 0 ms 5536 KB Correct answer: answer = 77137
28 Incorrect 9 ms 5536 KB Wrong answer: output = 0, expected = 764
29 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5536 KB Correct answer: answer = 4
2 Correct 0 ms 5536 KB Correct answer: answer = 4
3 Correct 0 ms 5536 KB Correct answer: answer = 4
4 Correct 0 ms 5536 KB Correct answer: answer = 12
5 Correct 0 ms 5536 KB Correct answer: answer = 52
6 Correct 0 ms 5536 KB Correct answer: answer = 210
7 Correct 0 ms 5536 KB Correct answer: answer = 88
8 Correct 0 ms 5536 KB Correct answer: answer = 7696
9 Correct 0 ms 5536 KB Correct answer: answer = 1
10 Correct 0 ms 5536 KB Correct answer: answer = 2374
11 Correct 0 ms 5536 KB Correct answer: answer = 9502
12 Correct 0 ms 5536 KB Correct answer: answer = 49
13 Correct 0 ms 5536 KB Correct answer: answer = 151
14 Correct 0 ms 5536 KB Correct answer: answer = 7550
15 Correct 0 ms 5536 KB Correct answer: answer = 7220
16 Correct 0 ms 5536 KB Correct answer: answer = 7550
17 Correct 0 ms 5536 KB Correct answer: answer = 10000
18 Correct 0 ms 5536 KB Correct answer: answer = 10000
19 Correct 0 ms 5536 KB Correct answer: answer = 624
20 Correct 0 ms 5536 KB Correct answer: answer = 10000
21 Correct 0 ms 5536 KB Correct answer: answer = 1
22 Correct 0 ms 5536 KB Correct answer: answer = 4
23 Correct 0 ms 5536 KB Correct answer: answer = 1
24 Correct 0 ms 5536 KB Correct answer: answer = 5
25 Correct 0 ms 5536 KB Correct answer: answer = 41
26 Correct 0 ms 5536 KB Correct answer: answer = 71923
27 Correct 0 ms 5536 KB Correct answer: answer = 77137
28 Incorrect 9 ms 5536 KB Wrong answer: output = 0, expected = 764
29 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5536 KB Correct answer: answer = 4
2 Correct 0 ms 5536 KB Correct answer: answer = 4
3 Correct 0 ms 5536 KB Correct answer: answer = 4
4 Correct 0 ms 5536 KB Correct answer: answer = 12
5 Correct 0 ms 5536 KB Correct answer: answer = 52
6 Correct 0 ms 5536 KB Correct answer: answer = 210
7 Correct 0 ms 5536 KB Correct answer: answer = 88
8 Correct 0 ms 5536 KB Correct answer: answer = 7696
9 Correct 0 ms 5536 KB Correct answer: answer = 1
10 Correct 0 ms 5536 KB Correct answer: answer = 2374
11 Correct 0 ms 5536 KB Correct answer: answer = 9502
12 Correct 0 ms 5536 KB Correct answer: answer = 49
13 Correct 0 ms 5536 KB Correct answer: answer = 151
14 Correct 0 ms 5536 KB Correct answer: answer = 7550
15 Correct 0 ms 5536 KB Correct answer: answer = 7220
16 Correct 0 ms 5536 KB Correct answer: answer = 7550
17 Correct 0 ms 5536 KB Correct answer: answer = 10000
18 Correct 0 ms 5536 KB Correct answer: answer = 10000
19 Correct 0 ms 5536 KB Correct answer: answer = 624
20 Correct 0 ms 5536 KB Correct answer: answer = 10000
21 Correct 0 ms 5536 KB Correct answer: answer = 1
22 Correct 0 ms 5536 KB Correct answer: answer = 4
23 Correct 0 ms 5536 KB Correct answer: answer = 1
24 Correct 0 ms 5536 KB Correct answer: answer = 5
25 Correct 0 ms 5536 KB Correct answer: answer = 41
26 Correct 0 ms 5536 KB Correct answer: answer = 71923
27 Correct 0 ms 5536 KB Correct answer: answer = 77137
28 Incorrect 9 ms 5536 KB Wrong answer: output = 0, expected = 764
29 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5536 KB Correct answer: answer = 4
2 Correct 0 ms 5536 KB Correct answer: answer = 4
3 Correct 0 ms 5536 KB Correct answer: answer = 4
4 Correct 0 ms 5536 KB Correct answer: answer = 12
5 Correct 0 ms 5536 KB Correct answer: answer = 52
6 Correct 0 ms 5536 KB Correct answer: answer = 210
7 Correct 0 ms 5536 KB Correct answer: answer = 88
8 Correct 0 ms 5536 KB Correct answer: answer = 7696
9 Correct 0 ms 5536 KB Correct answer: answer = 1
10 Correct 0 ms 5536 KB Correct answer: answer = 2374
11 Correct 0 ms 5536 KB Correct answer: answer = 9502
12 Correct 0 ms 5536 KB Correct answer: answer = 49
13 Correct 0 ms 5536 KB Correct answer: answer = 151
14 Correct 0 ms 5536 KB Correct answer: answer = 7550
15 Correct 0 ms 5536 KB Correct answer: answer = 7220
16 Correct 0 ms 5536 KB Correct answer: answer = 7550
17 Correct 0 ms 5536 KB Correct answer: answer = 10000
18 Correct 0 ms 5536 KB Correct answer: answer = 10000
19 Correct 0 ms 5536 KB Correct answer: answer = 624
20 Correct 0 ms 5536 KB Correct answer: answer = 10000
21 Correct 0 ms 5536 KB Correct answer: answer = 1
22 Correct 0 ms 5536 KB Correct answer: answer = 4
23 Correct 0 ms 5536 KB Correct answer: answer = 1
24 Correct 0 ms 5536 KB Correct answer: answer = 5
25 Correct 0 ms 5536 KB Correct answer: answer = 41
26 Correct 0 ms 5536 KB Correct answer: answer = 71923
27 Correct 0 ms 5536 KB Correct answer: answer = 77137
28 Incorrect 9 ms 5536 KB Wrong answer: output = 0, expected = 764
29 Halted 0 ms 0 KB -