Submission #1057067

# Submission time Handle Problem Language Result Execution time Memory
1057067 2024-08-13T13:51:39 Z noyancanturk Radio Towers (IOI22_towers) C++17
Compilation error
0 ms 0 KB
#include "fish.h"
  
#include<bits/stdc++.h>
using namespace std;
  
using lint=long long;
  
const int lim=3e3+100;
  
using pii=pair<int,lint>;
  
int n,m;
vector<int>inds[lim];
vector<lint> dp[lim],up[lim];
vector<pii>pref[lim];
lint p(int i,int l,int r){
  if(n<=i)return 0;
  auto rp=lower_bound(pref[i].begin(),pref[i].end(),pii{r+1,0}),
        lp=lower_bound(pref[i].begin(),pref[i].end(),pii{l,0});
  /*
  cerr<<"my i is "<<i<<"\n";
  cerr<<(rp-pref[i].begin())<<" rp\n";
  cerr<<r<<" :: ";
  cerr<<rp->first<<" "<<rp->second<<"\n";
  */
  rp--;
  if(lp==pref[i].begin())return rp->second;
  lp--;
  return rp->second-lp->second;
}
  
lint max_weights(int N,int M,vector<int>X,vector<int>Y,vector<int>W) {
  n=N,m=M;
  for(int i=0;i<m;i++){
    pref[X[i]].push_back({Y[i]+1,W[i]});
  }
  for(int i=0;i<n;i++){
    pref[i].push_back({0,0});
    sort(pref[i].begin(),pref[i].end());
    for(int j=0;j<size(pref[i]);j++){
      inds[i].push_back(pref[i][j].first);
    }
    for(int j=1;j<size(pref[i]);j++){
      pref[i][j].second+=pref[i][j-1].second;
    }
    /*
    cerr<<"pref "<<i<<" {\n";
    for(auto[f,s]:pref[i]){
      cerr<<"\b"<<f<<" "<<s<<"\n";
    }cerr<<"}\n";
    */
  }
  dp[0].resize(pref[0].size());
  up[0].resize(pref[0].size());
  for(int i=0;i<size(dp[0]);i++){
    dp[0][i]=pref[0][i].second;
    up[0][i]=0;
  }
  for(int i=1;i<n;i++){
    dp[i].resize(pref[i].size());
    up[i].resize(pref[i].size());
    lint max1=0;
    int pp=0;
    for(int j=0;j<size(dp[i]);j++){
      /*
  cerr<<"ok\n";
  cerr<<j<<" "<<size(dp[i])<<"\n";
  cerr<<pp<<" "<<size(up[i-1])<<"\n";
      */
      while(pp<size(up[i-1])&&inds[i-1][pp]<=inds[i][j]){
        max1=max(max1,up[i-1][pp]-p(i-1,0,inds[i-1][pp]));
        pp++;
      }
      /*
      cerr<<"bruh\n";
      cerr<<size(dp[i])<<" "<<size(up[i])<<" "<<size(inds[i])<<"\n";
      cerr<<j<<"\n";
      */
      dp[i][j]=max(dp[i][j],max1+p(i-1,0,inds[i][j])+p(i+1,0,inds[i][j]));
      //cerr<<"??\n";
      up[i][j]=max(up[i][j],max1+p(i-1,0,inds[i][j]));
      auto p=upper_bound(inds[i-1].begin(),inds[i-1].end(),inds[i][j]);
      if(p!=inds[i-1].begin()){
        //cerr<<"right here\n";
        p--;
        //cerr<<"it moved\n";
        up[i][j]=max(up[i][j],dp[i-1][p-inds[i-1].begin()]);
        //cerr<<"oops\n";
      }
      //cerr<<"ok i guess\n";
    }  
    max1=0;
    pp=size(up[i-1]);
    pp--;
    for(int j=int(size(dp[i]))-1;0<=j;j--){
      while(0<=pp&&inds[i][j]<=inds[i-1][pp]){
        max1=max(max1,dp[i-1][pp]);
        pp--;
      }
      dp[i][j]=max(dp[i][j],max1-p(i,0,inds[i][j])+p(i+1,0,inds[i][j]));
    }
  }
  lint ans=0;
  for(int i=0;i<size(dp[n-1]);i++){
    ans=max(ans,dp[n-1][i]);
  }
  return ans;
}

Compilation message

towers.cpp:1:10: fatal error: fish.h: No such file or directory
    1 | #include "fish.h"
      |          ^~~~~~~~
compilation terminated.