답안 #627069

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
627069 2022-08-12T06:25:26 Z nihaddhuseynli 메기 농장 (IOI22_fish) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define MAX 300001
#define INF 10000000001
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define ins insert
#define f first
#define s second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
ll n,t,r,m,k,res,x,y,sum;
string s;
set<pll> a[MAX];
set<ll> b[MAX];
bool comp(tuple <ll,ll,ll> x,tuple<ll,ll,ll> y){
    return get<0>(x)>get<0>(y);
}
ll max_weights(ll n,ll m, vector<int> c , vector <int> d , vector <int> e){
    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];
}
int main() {
  ll N, M;
  assert(2 == scanf("%d %d", &N, &M));
  n=N;
  m=M;
  std::vector<int> X(M), Y(M), W(M);
  for (int i = 0; i < M; ++i) {
    assert(3 == scanf("%d %d %d", &X[i], &Y[i], &W[i]));
  }
  for(int i=0;i<m;i++){
        ll k1,k2,k3;
        k1=X[i];
        k2=Y[i];
        k3=W[i];
        a[k1].insert(make_pair(n-k2-1,k3));
        b[k1].insert(n-k2-1);
  }
  long long result = max_weights(N, M, X, Y, W);
  printf("%lld\n", result);
  return 0;
}

Compilation message

In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from fish.cpp:1:
fish.cpp: In function 'int main()':
fish.cpp:68:21: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'll*' {aka 'long long int*'} [-Wformat=]
   68 |   assert(2 == scanf("%d %d", &N, &M));
      |                     ^~~~~~~  ~~
      |                              |
      |                              ll* {aka long long int*}
fish.cpp:68:23: note: format string is defined here
   68 |   assert(2 == scanf("%d %d", &N, &M));
      |                      ~^
      |                       |
      |                       int*
      |                      %lld
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from fish.cpp:1:
fish.cpp:68:21: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'll*' {aka 'long long int*'} [-Wformat=]
   68 |   assert(2 == scanf("%d %d", &N, &M));
      |                     ^~~~~~~      ~~
      |                                  |
      |                                  ll* {aka long long int*}
fish.cpp:68:26: note: format string is defined here
   68 |   assert(2 == scanf("%d %d", &N, &M));
      |                         ~^
      |                          |
      |                          int*
      |                         %lld
/usr/bin/ld: /tmp/cc1MhPXW.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccCvM5IV.o:fish.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/cc1MhPXW.o: in function `main':
grader.cpp:(.text.startup+0x25e): undefined reference to `max_weights(int, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status