Submission #627072

# Submission time Handle Problem Language Result Execution time Memory
627072 2022-08-12T06:35:07 Z nihaddhuseynli Catfish Farm (IOI22_fish) C++17
Compilation error
0 ms 0 KB
#include "fish.h"
#include <vector>
#define MAX 300001
typedef long long ll;
typedef pair<ll,ll> pll;
set<pll> a[MAX];
set<ll> b[MAX];
ll n,m,k;
long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W){
    n=N;
    m=M;
    for(int i=0;i<m;i++){
        a[i].insert(make_pair(n-Y[i]-1,W[i]));
        b[i].insert(n-Y[i]-1);
    }
    ll dp[n+1];
    dp[0]=0;
    dp[1]=0;
    ll h=n,sum=0;
    if(b[0].size()!=0){
        h=*b[0].begin();
        for(auto x:a[0]){
            sum+=x.second;
        }
        dp[1]=sum;
    }
    for(int i=2;i<=n;i++){
        dp[i]=dp[i-1];
        if(b[i-1].size()!=0){
            ll j;
            sum=0;
            j=distance(b[i-1].begin(),b[i-1].lower_bound(h-1));
            if(j==0){
                h=n;
            }
            else{
                h=*b[i-1].begin();
            }
            auto it=a[i-1].begin();
            ll z=0;
            while(it!=a[i-1].end() && z<j){
                dp[i]+=(*it).second;
                ++it;
                z++;
            }
            sum=0;
            for(auto x:a[i-1]){
                sum+=x.second;
            }
            if(sum+dp[i-2]>dp[i]){
                dp[i]=sum+dp[i-2];
                h=*b[i-1].begin();
            }
        }
        else{
            h=n;
        }
    }
    return dp[n];
}

Compilation message

fish.cpp:5:9: error: 'pair' does not name a type
    5 | typedef pair<ll,ll> pll;
      |         ^~~~
fish.cpp:6:1: error: 'set' does not name a type
    6 | set<pll> a[MAX];
      | ^~~
fish.cpp:7:1: error: 'set' does not name a type
    7 | set<ll> b[MAX];
      | ^~~
fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:13:9: error: 'a' was not declared in this scope
   13 |         a[i].insert(make_pair(n-Y[i]-1,W[i]));
      |         ^
fish.cpp:13:21: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'?
   13 |         a[i].insert(make_pair(n-Y[i]-1,W[i]));
      |                     ^~~~~~~~~
      |                     std::make_pair
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/vector:60,
                 from fish.h:1,
                 from fish.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:567:5: note: 'std::make_pair' declared here
  567 |     make_pair(_T1&& __x, _T2&& __y)
      |     ^~~~~~~~~
fish.cpp:14:9: error: 'b' was not declared in this scope
   14 |         b[i].insert(n-Y[i]-1);
      |         ^
fish.cpp:20:8: error: 'b' was not declared in this scope
   20 |     if(b[0].size()!=0){
      |        ^
fish.cpp:22:20: error: 'a' was not declared in this scope
   22 |         for(auto x:a[0]){
      |                    ^
fish.cpp:29:12: error: 'b' was not declared in this scope
   29 |         if(b[i-1].size()!=0){
      |            ^
fish.cpp:32:15: error: 'distance' was not declared in this scope; did you mean 'std::distance'?
   32 |             j=distance(b[i-1].begin(),b[i-1].lower_bound(h-1));
      |               ^~~~~~~~
      |               std::distance
In file included from /usr/include/c++/10/bits/stl_algobase.h:66,
                 from /usr/include/c++/10/vector:60,
                 from fish.h:1,
                 from fish.cpp:1:
/usr/include/c++/10/bits/stl_iterator_base_funcs.h:138:5: note: 'std::distance' declared here
  138 |     distance(_InputIterator __first, _InputIterator __last)
      |     ^~~~~~~~
fish.cpp:39:21: error: 'a' was not declared in this scope
   39 |             auto it=a[i-1].begin();
      |                     ^