結果

問題 No.468 役に立つ競技プログラミング実践編
ユーザー rickythetarickytheta
提出日時 2016-12-18 00:52:42
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 160 ms / 2,000 ms
コード長 1,842 bytes
コンパイル時間 1,265 ms
コンパイル使用メモリ 150,472 KB
実行使用メモリ 21,364 KB
最終ジャッジ日時 2023-08-21 00:16:52
合計ジャッジ時間 4,553 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
10,944 KB
testcase_01 AC 4 ms
10,896 KB
testcase_02 AC 3 ms
10,856 KB
testcase_03 AC 4 ms
10,820 KB
testcase_04 AC 4 ms
10,904 KB
testcase_05 AC 4 ms
10,952 KB
testcase_06 AC 4 ms
10,952 KB
testcase_07 AC 4 ms
10,832 KB
testcase_08 AC 4 ms
10,820 KB
testcase_09 AC 4 ms
10,916 KB
testcase_10 AC 4 ms
10,936 KB
testcase_11 AC 4 ms
10,888 KB
testcase_12 AC 4 ms
10,824 KB
testcase_13 AC 3 ms
10,868 KB
testcase_14 AC 5 ms
10,984 KB
testcase_15 AC 5 ms
11,008 KB
testcase_16 AC 5 ms
11,088 KB
testcase_17 AC 5 ms
11,052 KB
testcase_18 AC 5 ms
11,016 KB
testcase_19 AC 4 ms
10,996 KB
testcase_20 AC 5 ms
10,932 KB
testcase_21 AC 5 ms
10,968 KB
testcase_22 AC 5 ms
10,916 KB
testcase_23 AC 4 ms
11,176 KB
testcase_24 AC 147 ms
21,136 KB
testcase_25 AC 146 ms
21,128 KB
testcase_26 AC 148 ms
21,256 KB
testcase_27 AC 151 ms
21,232 KB
testcase_28 AC 147 ms
21,216 KB
testcase_29 AC 148 ms
21,144 KB
testcase_30 AC 160 ms
21,364 KB
testcase_31 AC 158 ms
21,160 KB
testcase_32 AC 153 ms
21,124 KB
testcase_33 AC 152 ms
21,164 KB
testcase_34 AC 46 ms
18,040 KB
testcase_35 AC 4 ms
10,976 KB
testcase_36 AC 4 ms
10,864 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,m;
vector<pii> g[125252];
int inn[125252];
int mxd[125252];
int mnd[125252];

vector<pii> rev[125252];
int inn2[125252];
int d2[125252];

int crit[125252];

int main(){
  scanf("%d%d",&n,&m);
  REP(i,m){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    g[a].push_back(pii(b,c));
    rev[b].push_back(pii(a,c));
    inn[b]++;
    inn2[a]++;
  }
  vi V;
  REP(i,n)mxd[i]=-1, mnd[i]=1e9, d2[i]=1e9;

  V.clear();
  mxd[0] = mnd[0] = 0;
  REP(i,n)if(inn[i]==0)V.push_back(i);
  REP(i,n){
    int p = V[i];
    for(pii P:g[p]){
      CHMIN(mnd[P.first],mxd[p]+P.second);
      CHMAX(mxd[P.first],mxd[p]+P.second);
      if(--inn[P.first]==0)V.push_back(P.first);
    }
  }

  V.clear();
  d2[n-1] = mxd[n-1];
  REP(i,n)if(inn2[i]==0)V.push_back(i);
  REP(i,n){
    int p = V[i];
    for(pii P:rev[p]){
      CHMIN(d2[P.first],d2[p]-P.second);
      if(--inn2[P.first]==0)V.push_back(P.first);
    }
  }
  int ans = n;
  REP(i,n)if(d2[i]==mxd[i])ans--;
  printf("%d %d/%d\n",mxd[n-1],ans,n);
  return 0;
}
0