Submission #23413

# Submission time Handle Problem Language Result Execution time Memory
23413 2017-05-08T19:55:15 Z Bruteforceman Aliens (IOI16_aliens) C++11
16 / 100
143 ms 2088 KB
#define JUDGE

#ifndef JUDGE
#include "aliens.h"
#endif // JUDGE

#include "bits/stdc++.h"
using namespace std;

typedef pair <int, int> pii;
vector <pii> range;

bool comp(pii a, pii b) {
    if(a.first == b.first) {
        return a.second > b.second;
    } else {
        return a.first < b.first;
    }
}

long long count(int x, int y) {
    if(x <= y) return 1LL * (y - x + 1) * (y - x + 1);
    return 0;
}
long long dp[2][4005];

long long take_photos(int n, int m, int k, std::vector<int> r, std::vector<int> c) {
    set <pii> all;
    for(int i = 0; i < n; i++) {
        int x = min(r[i], c[i]);
        int y = max(r[i], c[i]);
        all.insert(make_pair(x, y));
    }
 //   const int inf = 1e8;
    const long long INF = 1e16;

    /*
    multiset <int> s;
    vector <pii> sweep;
    for(int i = 0; i < n; i++) {
        sweep.push_back(make_pair(range[i].first, inf));
        sweep.push_back(make_pair(range[i].second, range[i].first));
    }
    sort(sweep.begin(), sweep.end(), comp);
    range.clear();

    for(int i = 0; i < n+n; i++) {
        if(sweep[i].second == inf) {
            s.insert(sweep[i].first);
        } else {
            if(*s.begin() == sweep[i].second) {
                if(s.size() == 1 || *(++s.begin()) != sweep[i].second) range.push_back(pii(sweep[i].second, sweep[i].first));
            }
            s.erase(s.find(sweep[i].second));
        }
    }*/
    vector <pii> aux (all.begin(), all.end());
    for(auto i : aux) {
        bool good = true;
        for(auto j : aux) {
            if(i == j) continue;
            if(j.first <= i.first && i.second <= j.second) {
                good = false;
            }
        }
        if(good) range.push_back(i);
    }

    range.push_back(make_pair(-1, -1));
    sort(range.begin(), range.end());
    int sz = range.size() - 1;

    memset(dp, 0, sizeof dp);
    for(int i = 1; i <= sz; i++) {
        dp[0][i] = INF;
    }
    int ro = 0;
    for(int i = 1; i <= k; i++) {
        ro ^= 1;
        for(int j = 1; j <= sz; j++) {
            dp[ro][j] = INF;
            for(int l = 1; l <= j; l++) {
                dp[ro][j] = min(dp[ro][j], dp[ro ^ 1][l - 1] + count(range[l].first, range[j].second) - count(range[j].first, range[l-1].second));
            }
        }
    }
    return dp[ro][sz];
}

#ifndef JUDGE
int main() {
    int n, m, k;
    assert(3 == scanf("%d %d %d", &n, &m, &k));
    std::vector<int> r(n), c(n);
    for (int i = 0; i < n; i++) {
        assert(2 == scanf("%d %d", &r[i], &c[i]));
    }
    long long ans = take_photos(n, m, k, r, c);

    printf("%lld\n", ans);
    return 0;
}
#endif // JUDGE
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2088 KB Correct answer: answer = 4
2 Correct 0 ms 2088 KB Correct answer: answer = 4
3 Correct 0 ms 2088 KB Correct answer: answer = 4
4 Correct 0 ms 2088 KB Correct answer: answer = 12
5 Correct 0 ms 2088 KB Correct answer: answer = 52
6 Correct 0 ms 2088 KB Correct answer: answer = 210
7 Correct 0 ms 2088 KB Correct answer: answer = 88
8 Correct 0 ms 2088 KB Correct answer: answer = 7696
9 Correct 0 ms 2088 KB Correct answer: answer = 1
10 Correct 0 ms 2088 KB Correct answer: answer = 2374
11 Correct 0 ms 2088 KB Correct answer: answer = 9502
12 Correct 0 ms 2088 KB Correct answer: answer = 49
13 Correct 0 ms 2088 KB Correct answer: answer = 151
14 Correct 0 ms 2088 KB Correct answer: answer = 7550
15 Correct 0 ms 2088 KB Correct answer: answer = 7220
16 Correct 0 ms 2088 KB Correct answer: answer = 7550
17 Correct 0 ms 2088 KB Correct answer: answer = 10000
18 Correct 0 ms 2088 KB Correct answer: answer = 10000
19 Correct 0 ms 2088 KB Correct answer: answer = 624
20 Correct 0 ms 2088 KB Correct answer: answer = 10000
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2088 KB Correct answer: answer = 1
2 Correct 0 ms 2088 KB Correct answer: answer = 4
3 Correct 0 ms 2088 KB Correct answer: answer = 1
4 Correct 0 ms 2088 KB Correct answer: answer = 5
5 Correct 0 ms 2088 KB Correct answer: answer = 41
6 Correct 0 ms 2088 KB Correct answer: answer = 71923
7 Correct 0 ms 2088 KB Correct answer: answer = 77137
8 Correct 43 ms 2088 KB Correct answer: answer = 764
9 Correct 0 ms 2088 KB Correct answer: answer = 250000
10 Correct 143 ms 2088 KB Correct answer: answer = 500
11 Correct 0 ms 2088 KB Correct answer: answer = 32
12 Correct 0 ms 2088 KB Correct answer: answer = 130050
13 Correct 13 ms 2088 KB Correct answer: answer = 5110
14 Correct 0 ms 2088 KB Correct answer: answer = 2626
15 Correct 6 ms 2088 KB Correct answer: answer = 796
16 Correct 9 ms 2088 KB Correct answer: answer = 7580
17 Correct 36 ms 2088 KB Correct answer: answer = 1904
18 Correct 0 ms 2088 KB Correct answer: answer = 996004
19 Correct 6 ms 2088 KB Correct answer: answer = 38817
20 Correct 19 ms 2088 KB Correct answer: answer = 4096
21 Correct 0 ms 2088 KB Correct answer: answer = 1
22 Correct 0 ms 2088 KB Correct answer: answer = 1
23 Correct 43 ms 2088 KB Correct answer: answer = 2040
24 Correct 0 ms 2088 KB Correct answer: answer = 2
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2088 KB Correct answer: answer = 4
2 Correct 0 ms 2088 KB Correct answer: answer = 4
3 Correct 0 ms 2088 KB Correct answer: answer = 4
4 Correct 0 ms 2088 KB Correct answer: answer = 12
5 Correct 0 ms 2088 KB Correct answer: answer = 52
6 Correct 0 ms 2088 KB Correct answer: answer = 210
7 Correct 0 ms 2088 KB Correct answer: answer = 88
8 Correct 0 ms 2088 KB Correct answer: answer = 7696
9 Correct 0 ms 2088 KB Correct answer: answer = 1
10 Correct 0 ms 2088 KB Correct answer: answer = 2374
11 Correct 0 ms 2088 KB Correct answer: answer = 9502
12 Correct 0 ms 2088 KB Correct answer: answer = 49
13 Correct 0 ms 2088 KB Correct answer: answer = 151
14 Correct 0 ms 2088 KB Correct answer: answer = 7550
15 Correct 0 ms 2088 KB Correct answer: answer = 7220
16 Correct 0 ms 2088 KB Correct answer: answer = 7550
17 Correct 0 ms 2088 KB Correct answer: answer = 10000
18 Correct 0 ms 2088 KB Correct answer: answer = 10000
19 Correct 0 ms 2088 KB Correct answer: answer = 624
20 Correct 0 ms 2088 KB Correct answer: answer = 10000
21 Correct 0 ms 2088 KB Correct answer: answer = 1
22 Correct 0 ms 2088 KB Correct answer: answer = 4
23 Correct 0 ms 2088 KB Correct answer: answer = 1
24 Correct 0 ms 2088 KB Correct answer: answer = 5
25 Correct 0 ms 2088 KB Correct answer: answer = 41
26 Correct 0 ms 2088 KB Correct answer: answer = 71923
27 Correct 0 ms 2088 KB Correct answer: answer = 77137
28 Correct 43 ms 2088 KB Correct answer: answer = 764
29 Correct 0 ms 2088 KB Correct answer: answer = 250000
30 Correct 143 ms 2088 KB Correct answer: answer = 500
31 Correct 0 ms 2088 KB Correct answer: answer = 32
32 Correct 0 ms 2088 KB Correct answer: answer = 130050
33 Correct 13 ms 2088 KB Correct answer: answer = 5110
34 Correct 0 ms 2088 KB Correct answer: answer = 2626
35 Correct 6 ms 2088 KB Correct answer: answer = 796
36 Correct 9 ms 2088 KB Correct answer: answer = 7580
37 Correct 36 ms 2088 KB Correct answer: answer = 1904
38 Correct 0 ms 2088 KB Correct answer: answer = 996004
39 Correct 6 ms 2088 KB Correct answer: answer = 38817
40 Correct 19 ms 2088 KB Correct answer: answer = 4096
41 Correct 0 ms 2088 KB Correct answer: answer = 1
42 Correct 0 ms 2088 KB Correct answer: answer = 1
43 Correct 43 ms 2088 KB Correct answer: answer = 2040
44 Correct 0 ms 2088 KB Correct answer: answer = 2
45 Correct 0 ms 2088 KB Correct answer: answer = 4
46 Correct 0 ms 2088 KB Correct answer: answer = 9
47 Correct 0 ms 2088 KB Correct answer: answer = 9
48 Correct 0 ms 2088 KB Correct answer: answer = 21
49 Incorrect 0 ms 2088 KB Wrong answer: output = 73, expected = 71
50 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2088 KB Correct answer: answer = 4
2 Correct 0 ms 2088 KB Correct answer: answer = 4
3 Correct 0 ms 2088 KB Correct answer: answer = 4
4 Correct 0 ms 2088 KB Correct answer: answer = 12
5 Correct 0 ms 2088 KB Correct answer: answer = 52
6 Correct 0 ms 2088 KB Correct answer: answer = 210
7 Correct 0 ms 2088 KB Correct answer: answer = 88
8 Correct 0 ms 2088 KB Correct answer: answer = 7696
9 Correct 0 ms 2088 KB Correct answer: answer = 1
10 Correct 0 ms 2088 KB Correct answer: answer = 2374
11 Correct 0 ms 2088 KB Correct answer: answer = 9502
12 Correct 0 ms 2088 KB Correct answer: answer = 49
13 Correct 0 ms 2088 KB Correct answer: answer = 151
14 Correct 0 ms 2088 KB Correct answer: answer = 7550
15 Correct 0 ms 2088 KB Correct answer: answer = 7220
16 Correct 0 ms 2088 KB Correct answer: answer = 7550
17 Correct 0 ms 2088 KB Correct answer: answer = 10000
18 Correct 0 ms 2088 KB Correct answer: answer = 10000
19 Correct 0 ms 2088 KB Correct answer: answer = 624
20 Correct 0 ms 2088 KB Correct answer: answer = 10000
21 Correct 0 ms 2088 KB Correct answer: answer = 1
22 Correct 0 ms 2088 KB Correct answer: answer = 4
23 Correct 0 ms 2088 KB Correct answer: answer = 1
24 Correct 0 ms 2088 KB Correct answer: answer = 5
25 Correct 0 ms 2088 KB Correct answer: answer = 41
26 Correct 0 ms 2088 KB Correct answer: answer = 71923
27 Correct 0 ms 2088 KB Correct answer: answer = 77137
28 Correct 43 ms 2088 KB Correct answer: answer = 764
29 Correct 0 ms 2088 KB Correct answer: answer = 250000
30 Correct 143 ms 2088 KB Correct answer: answer = 500
31 Correct 0 ms 2088 KB Correct answer: answer = 32
32 Correct 0 ms 2088 KB Correct answer: answer = 130050
33 Correct 13 ms 2088 KB Correct answer: answer = 5110
34 Correct 0 ms 2088 KB Correct answer: answer = 2626
35 Correct 6 ms 2088 KB Correct answer: answer = 796
36 Correct 9 ms 2088 KB Correct answer: answer = 7580
37 Correct 36 ms 2088 KB Correct answer: answer = 1904
38 Correct 0 ms 2088 KB Correct answer: answer = 996004
39 Correct 6 ms 2088 KB Correct answer: answer = 38817
40 Correct 19 ms 2088 KB Correct answer: answer = 4096
41 Correct 0 ms 2088 KB Correct answer: answer = 1
42 Correct 0 ms 2088 KB Correct answer: answer = 1
43 Correct 43 ms 2088 KB Correct answer: answer = 2040
44 Correct 0 ms 2088 KB Correct answer: answer = 2
45 Correct 0 ms 2088 KB Correct answer: answer = 4
46 Correct 0 ms 2088 KB Correct answer: answer = 9
47 Correct 0 ms 2088 KB Correct answer: answer = 9
48 Correct 0 ms 2088 KB Correct answer: answer = 21
49 Incorrect 0 ms 2088 KB Wrong answer: output = 73, expected = 71
50 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2088 KB Correct answer: answer = 4
2 Correct 0 ms 2088 KB Correct answer: answer = 4
3 Correct 0 ms 2088 KB Correct answer: answer = 4
4 Correct 0 ms 2088 KB Correct answer: answer = 12
5 Correct 0 ms 2088 KB Correct answer: answer = 52
6 Correct 0 ms 2088 KB Correct answer: answer = 210
7 Correct 0 ms 2088 KB Correct answer: answer = 88
8 Correct 0 ms 2088 KB Correct answer: answer = 7696
9 Correct 0 ms 2088 KB Correct answer: answer = 1
10 Correct 0 ms 2088 KB Correct answer: answer = 2374
11 Correct 0 ms 2088 KB Correct answer: answer = 9502
12 Correct 0 ms 2088 KB Correct answer: answer = 49
13 Correct 0 ms 2088 KB Correct answer: answer = 151
14 Correct 0 ms 2088 KB Correct answer: answer = 7550
15 Correct 0 ms 2088 KB Correct answer: answer = 7220
16 Correct 0 ms 2088 KB Correct answer: answer = 7550
17 Correct 0 ms 2088 KB Correct answer: answer = 10000
18 Correct 0 ms 2088 KB Correct answer: answer = 10000
19 Correct 0 ms 2088 KB Correct answer: answer = 624
20 Correct 0 ms 2088 KB Correct answer: answer = 10000
21 Correct 0 ms 2088 KB Correct answer: answer = 1
22 Correct 0 ms 2088 KB Correct answer: answer = 4
23 Correct 0 ms 2088 KB Correct answer: answer = 1
24 Correct 0 ms 2088 KB Correct answer: answer = 5
25 Correct 0 ms 2088 KB Correct answer: answer = 41
26 Correct 0 ms 2088 KB Correct answer: answer = 71923
27 Correct 0 ms 2088 KB Correct answer: answer = 77137
28 Correct 43 ms 2088 KB Correct answer: answer = 764
29 Correct 0 ms 2088 KB Correct answer: answer = 250000
30 Correct 143 ms 2088 KB Correct answer: answer = 500
31 Correct 0 ms 2088 KB Correct answer: answer = 32
32 Correct 0 ms 2088 KB Correct answer: answer = 130050
33 Correct 13 ms 2088 KB Correct answer: answer = 5110
34 Correct 0 ms 2088 KB Correct answer: answer = 2626
35 Correct 6 ms 2088 KB Correct answer: answer = 796
36 Correct 9 ms 2088 KB Correct answer: answer = 7580
37 Correct 36 ms 2088 KB Correct answer: answer = 1904
38 Correct 0 ms 2088 KB Correct answer: answer = 996004
39 Correct 6 ms 2088 KB Correct answer: answer = 38817
40 Correct 19 ms 2088 KB Correct answer: answer = 4096
41 Correct 0 ms 2088 KB Correct answer: answer = 1
42 Correct 0 ms 2088 KB Correct answer: answer = 1
43 Correct 43 ms 2088 KB Correct answer: answer = 2040
44 Correct 0 ms 2088 KB Correct answer: answer = 2
45 Correct 0 ms 2088 KB Correct answer: answer = 4
46 Correct 0 ms 2088 KB Correct answer: answer = 9
47 Correct 0 ms 2088 KB Correct answer: answer = 9
48 Correct 0 ms 2088 KB Correct answer: answer = 21
49 Incorrect 0 ms 2088 KB Wrong answer: output = 73, expected = 71
50 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2088 KB Correct answer: answer = 4
2 Correct 0 ms 2088 KB Correct answer: answer = 4
3 Correct 0 ms 2088 KB Correct answer: answer = 4
4 Correct 0 ms 2088 KB Correct answer: answer = 12
5 Correct 0 ms 2088 KB Correct answer: answer = 52
6 Correct 0 ms 2088 KB Correct answer: answer = 210
7 Correct 0 ms 2088 KB Correct answer: answer = 88
8 Correct 0 ms 2088 KB Correct answer: answer = 7696
9 Correct 0 ms 2088 KB Correct answer: answer = 1
10 Correct 0 ms 2088 KB Correct answer: answer = 2374
11 Correct 0 ms 2088 KB Correct answer: answer = 9502
12 Correct 0 ms 2088 KB Correct answer: answer = 49
13 Correct 0 ms 2088 KB Correct answer: answer = 151
14 Correct 0 ms 2088 KB Correct answer: answer = 7550
15 Correct 0 ms 2088 KB Correct answer: answer = 7220
16 Correct 0 ms 2088 KB Correct answer: answer = 7550
17 Correct 0 ms 2088 KB Correct answer: answer = 10000
18 Correct 0 ms 2088 KB Correct answer: answer = 10000
19 Correct 0 ms 2088 KB Correct answer: answer = 624
20 Correct 0 ms 2088 KB Correct answer: answer = 10000
21 Correct 0 ms 2088 KB Correct answer: answer = 1
22 Correct 0 ms 2088 KB Correct answer: answer = 4
23 Correct 0 ms 2088 KB Correct answer: answer = 1
24 Correct 0 ms 2088 KB Correct answer: answer = 5
25 Correct 0 ms 2088 KB Correct answer: answer = 41
26 Correct 0 ms 2088 KB Correct answer: answer = 71923
27 Correct 0 ms 2088 KB Correct answer: answer = 77137
28 Correct 43 ms 2088 KB Correct answer: answer = 764
29 Correct 0 ms 2088 KB Correct answer: answer = 250000
30 Correct 143 ms 2088 KB Correct answer: answer = 500
31 Correct 0 ms 2088 KB Correct answer: answer = 32
32 Correct 0 ms 2088 KB Correct answer: answer = 130050
33 Correct 13 ms 2088 KB Correct answer: answer = 5110
34 Correct 0 ms 2088 KB Correct answer: answer = 2626
35 Correct 6 ms 2088 KB Correct answer: answer = 796
36 Correct 9 ms 2088 KB Correct answer: answer = 7580
37 Correct 36 ms 2088 KB Correct answer: answer = 1904
38 Correct 0 ms 2088 KB Correct answer: answer = 996004
39 Correct 6 ms 2088 KB Correct answer: answer = 38817
40 Correct 19 ms 2088 KB Correct answer: answer = 4096
41 Correct 0 ms 2088 KB Correct answer: answer = 1
42 Correct 0 ms 2088 KB Correct answer: answer = 1
43 Correct 43 ms 2088 KB Correct answer: answer = 2040
44 Correct 0 ms 2088 KB Correct answer: answer = 2
45 Correct 0 ms 2088 KB Correct answer: answer = 4
46 Correct 0 ms 2088 KB Correct answer: answer = 9
47 Correct 0 ms 2088 KB Correct answer: answer = 9
48 Correct 0 ms 2088 KB Correct answer: answer = 21
49 Incorrect 0 ms 2088 KB Wrong answer: output = 73, expected = 71
50 Halted 0 ms 0 KB -