Submission #35077835


Source Code Expand

#include <bits/stdc++.h>
#include <atcoder/mincostflow>
using namespace std;

typedef long long ll;
#define rep(i,a,n) for (ll i=a;i<(ll)n;i++)
#define per(i,a,n) for (ll i=n;i-->(ll)a;)
#define pb push_back

ll read(){ll r;scanf("%lld",&r);return r;}

int main(){
  int n = read(); // 3e4
  const int N = 150;
  const int S = N*2;
  const int T = S+1;
  atcoder::mcf_graph<ll,ll> g(T+1);
  rep(i,0,N) g.add_edge(S,i,1,0);
  rep(i,0,N) g.add_edge(N+i,T,1,0);
  ll MAX = 1e9;
  rep(i,0,n){
    int a = read()-1;
    int b = read()-1 + N;
    int c = read();
    g.add_edge(a,b,1,MAX-c);
  }
  auto points = g.slope(S,T); // 包含{0,0}
  vector<pair<ll,ll>> ans;
  for(auto [f1,c1]:points){
    if(ans.size() != 0 && ans.back().first+1 != f1){
      auto [f0,c0] = ans.back();
      rep(f,f0+1,f1) ans.push_back({f,c0 + (c1-c0)/(f1-f0)*(f-f0)}); // [f0+1..f1-1]
    }
    ans.push_back({f1,c1});
  }
  printf("%d\n",(int)ans.size()-1);
  rep(i,1,ans.size()) printf("%lld\n",MAX*ans[i].first - ans[i].second);
  return 0;
}

Submission Info

Submission Time
Task G - Dream Team
User cromarmot
Language C++ (GCC 9.2.1)
Score 600
Code Size 1023 Byte
Status AC
Exec Time 35 ms
Memory 7696 KiB

Compile Error

./Main.cpp: In function ‘ll read()’:
./Main.cpp:10:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   10 | ll read(){ll r;scanf("%lld",&r);return r;}
      |                ~~~~~^~~~~~~~~~~

Judge Result

Set Name Sample All After_Contest
Score / Max Score 0 / 0 600 / 600 0 / 0
Status
AC × 2
AC × 32
AC × 1
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt, random_30.txt, sample_01.txt, sample_02.txt
After_Contest after_contest_01.txt
Case Name Status Exec Time Memory
after_contest_01.txt AC 6 ms 3616 KiB
random_01.txt AC 2 ms 3672 KiB
random_02.txt AC 4 ms 3640 KiB
random_03.txt AC 3 ms 3676 KiB
random_04.txt AC 22 ms 6464 KiB
random_05.txt AC 24 ms 6416 KiB
random_06.txt AC 29 ms 6416 KiB
random_07.txt AC 29 ms 6528 KiB
random_08.txt AC 35 ms 7696 KiB
random_09.txt AC 34 ms 7524 KiB
random_10.txt AC 31 ms 7696 KiB
random_11.txt AC 18 ms 5592 KiB
random_12.txt AC 34 ms 7568 KiB
random_13.txt AC 18 ms 4500 KiB
random_14.txt AC 29 ms 7568 KiB
random_15.txt AC 18 ms 5152 KiB
random_16.txt AC 33 ms 7512 KiB
random_17.txt AC 29 ms 6608 KiB
random_18.txt AC 33 ms 7648 KiB
random_19.txt AC 11 ms 3644 KiB
random_20.txt AC 35 ms 7524 KiB
random_21.txt AC 28 ms 6400 KiB
random_22.txt AC 33 ms 7432 KiB
random_23.txt AC 17 ms 5032 KiB
random_24.txt AC 32 ms 7656 KiB
random_25.txt AC 30 ms 7520 KiB
random_26.txt AC 28 ms 7580 KiB
random_27.txt AC 13 ms 4144 KiB
random_28.txt AC 34 ms 7528 KiB
random_29.txt AC 11 ms 3876 KiB
random_30.txt AC 3 ms 3724 KiB
sample_01.txt AC 2 ms 3624 KiB
sample_02.txt AC 2 ms 3812 KiB