結果

問題 No.468 役に立つ競技プログラミング実践編
ユーザー 👑 kmjpkmjp
提出日時 2016-12-18 00:14:12
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 199 ms / 2,000 ms
コード長 1,356 bytes
コンパイル時間 1,739 ms
コンパイル使用メモリ 169,584 KB
実行使用メモリ 38,016 KB
最終ジャッジ日時 2024-05-08 04:19:24
合計ジャッジ時間 5,904 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
27,008 KB
testcase_01 AC 12 ms
27,008 KB
testcase_02 AC 14 ms
27,008 KB
testcase_03 AC 12 ms
27,008 KB
testcase_04 AC 12 ms
27,136 KB
testcase_05 AC 12 ms
27,136 KB
testcase_06 AC 12 ms
27,008 KB
testcase_07 AC 12 ms
27,008 KB
testcase_08 AC 12 ms
27,136 KB
testcase_09 AC 13 ms
27,008 KB
testcase_10 AC 12 ms
27,008 KB
testcase_11 AC 13 ms
27,008 KB
testcase_12 AC 12 ms
27,136 KB
testcase_13 AC 12 ms
27,008 KB
testcase_14 AC 13 ms
27,264 KB
testcase_15 AC 14 ms
27,264 KB
testcase_16 AC 13 ms
27,136 KB
testcase_17 AC 14 ms
27,264 KB
testcase_18 AC 13 ms
27,136 KB
testcase_19 AC 13 ms
27,136 KB
testcase_20 AC 13 ms
27,136 KB
testcase_21 AC 13 ms
27,136 KB
testcase_22 AC 14 ms
27,136 KB
testcase_23 AC 14 ms
27,264 KB
testcase_24 AC 190 ms
37,888 KB
testcase_25 AC 191 ms
37,888 KB
testcase_26 AC 187 ms
38,016 KB
testcase_27 AC 199 ms
37,888 KB
testcase_28 AC 192 ms
37,888 KB
testcase_29 AC 188 ms
38,016 KB
testcase_30 AC 196 ms
37,888 KB
testcase_31 AC 194 ms
38,016 KB
testcase_32 AC 190 ms
38,016 KB
testcase_33 AC 191 ms
37,888 KB
testcase_34 AC 55 ms
34,816 KB
testcase_35 AC 12 ms
27,264 KB
testcase_36 AC 12 ms
27,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M;
vector<pair<int,int>> E[2][505050];
int st[2][505050];
int W[2][505050];

void solve() {
	int i,j,k,l,r,x,y; string s;
	cin>>N>>M;
	FOR(i,M) {
		cin>>x>>y>>r;
		E[0][x].push_back({y,r});
		E[1][y].push_back({x,r});
		W[0][y]++;
		W[1][x]++;
	}
	queue<int> Q;
	FOR(i,N) {
		if(W[0][i]==0) Q.push(i);
		if(W[1][i]==0) Q.push(i+100000);
	}
	while(Q.size()) {
		int k=Q.front()%100000;
		int t=Q.front()/100000;
		
		Q.pop();
		FORR(r,E[t][k]) {
			st[t][r.first] = max(st[t][r.first],st[t][k]+r.second);
			if(--W[t][r.first]==0) Q.push(r.first+t*100000);
		}
	}
	
	int ret=0;
	FOR(i,N) if(st[0][i]+st[1][i] != st[0][N-1]+st[1][N-1]) ret++;
	cout<<st[0][N-1]<<" "<<ret<<"/"<<N<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}
0