답안 #339860

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
339860 2020-12-26T10:06:36 Z Vladth11 Mountains (IOI17_mountains) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define debug(x) cerr << #x << " " << x << "\n"
#define debug_with_space(x) cerr << #x << " " << x << " "
#include "mountains.h"

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair <ll, ll> pii;
typedef pair <ll, pii> piii;
typedef tree <pii, null_type, less <pii>, rb_tree_tag, tree_order_statistics_node_update> OST;

const ll NMAX = 2001;
const ll INF = (1LL << 60);
const ll MOD = 1000000007;
const ll BLOCK = 101;
const ll nr_of_bits = 35;

ll dp[NMAX][NMAX];

class ConvexHull{
    pii stiva[NMAX];
    ll vf;
    bool OK(pii a, pii b, pii c){
        return ((a.first * (b.second - c.second) + b.first * (c.second - a.second) + c.first * (a.second - b.second)) <= 0);
    }
public:
    ll size(){
        return vf;
    }
    ll last(){
        return stiva[vf].first;
    }
    ll lastbutone(){
        return stiva[vf - 1].first;
    }
    void push(pii x){
        while(vf > 1 && OK(stiva[vf], stiva[vf - 1], x)){
            vf--;
        }
        stiva[++vf] = x;
    }
}hull;

ll maximum_deevs(vector<ll> y) {
    ll i, j, maxim = 0;
    ll n = y.size();
    for(i = n; i >= 1; i--) {
        for(j = i; j <= n; j++) {
            hull.push({j, y[j - 1]});
            ll ultim = hull.last();
            if(i == j)
                dp[i][j] = 1;
            dp[i][j] = max(dp[i][j], dp[i][ultim - 1] + dp[ultim + 1][j]);
            if(hull.size() > 1) {
                ll penultim = hull.lastbutone();
                dp[i][j] = max(dp[i][j], dp[i][penultim - 1] + dp[penultim + 1][j]);
            }
            maxim = max(maxim, dp[i][j]);
        }
    }
    return maxim;
}

ll main() {
    ll n;
    assert(1 == scanf("%d", &n));
    std::vector<ll> y(n);
    for (ll i = 0; i < n; i++) {
        assert(1 == scanf("%d", &y[i]));
    }
    ll result = maximum_deevs(y);
    prllf("%d\n", result);
    return 0;
}

Compilation message

mountains.cpp:67:1: error: '::main' must return 'int'
   67 | ll main() {
      | ^~
In file included from /usr/include/c++/9/ext/pb_ds/detail/pat_trie_/pat_trie_.hpp:45,
                 from /usr/include/c++/9/ext/pb_ds/detail/container_base_dispatch.hpp:90,
                 from /usr/include/c++/9/ext/pb_ds/assoc_container.hpp:48,
                 from mountains.cpp:2:
mountains.cpp: In function 'int main()':
mountains.cpp:69:23: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'll*' {aka 'long long int*'} [-Wformat=]
   69 |     assert(1 == scanf("%d", &n));
      |                       ^~~~  ~~
      |                             |
      |                             ll* {aka long long int*}
mountains.cpp:69:25: note: format string is defined here
   69 |     assert(1 == scanf("%d", &n));
      |                        ~^
      |                         |
      |                         int*
      |                        %lld
In file included from /usr/include/c++/9/ext/pb_ds/detail/pat_trie_/pat_trie_.hpp:45,
                 from /usr/include/c++/9/ext/pb_ds/detail/container_base_dispatch.hpp:90,
                 from /usr/include/c++/9/ext/pb_ds/assoc_container.hpp:48,
                 from mountains.cpp:2:
mountains.cpp:72:27: warning: format '%d' expects argument of type 'int*', but argument 2 has type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type*' {aka 'long long int*'} [-Wformat=]
   72 |         assert(1 == scanf("%d", &y[i]));
      |                           ^~~~
mountains.cpp:72:29: note: format string is defined here
   72 |         assert(1 == scanf("%d", &y[i]));
      |                            ~^
      |                             |
      |                             int*
      |                            %lld
mountains.cpp:75:5: error: 'prllf' was not declared in this scope
   75 |     prllf("%d\n", result);
      |     ^~~~~