Submission #627077

# Submission time Handle Problem Language Result Execution time Memory
627077 2022-08-12T06:37:56 Z nihaddhuseynli Catfish Farm (IOI22_fish) C++17
Compilation error
0 ms 0 KB
#include "fish.h"
#include <bits/stdc++.h>
#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; did you mean 'setns'?
    6 | set<pll> a[MAX];
      | ^~~
      | setns
fish.cpp:7:1: error: 'set' does not name a type; did you mean 'setns'?
    7 | set<ll> b[MAX];
      | ^~~
      | setns
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/filesystem:45,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from fish.cpp:2:
/usr/include/c++/10/bits/fs_path.h:1348:1: note: 'std::distance' declared here
 1348 | distance(filesystem::path::iterator __first, filesystem::path::iterator __last)
      | ^~~~~~~~
fish.cpp:39:21: error: 'a' was not declared in this scope
   39 |             auto it=a[i-1].begin();
      |                     ^