Submission #262591

# Submission time Handle Problem Language Result Execution time Memory
262591 2020-08-13T04:53:07 Z 임성재(#5086) Training (IOI07_training) C++17
0 / 100
2 ms 640 KB
#include<bits/stdc++.h>
using namespace std;

#define fast ios::sync_with_stdio(false); cin.tie(0);
#define pre(a) cout << fixed; cout.precision(a);
#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define all(v) (v).begin() (v).end()
#define mp make_pair

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> ti;
const ll INF = 1e18;
const int inf = 1e9;

int n, m;
vector<int> G[1010];
vector<pii> g[1010];
vector<ti> e;
int num[1010];
int dp[1010];
int ans;

void Dfs(int x, int p) {
	for(auto i : G[x]) {
		if(i == p) continue;

		num[i] = num[x] + 1;
		Dfs(i, x);
	}
}

int main() {
	fast;
	cin >> n >> m;

	for(int i=0; i<m; i++) {
		int u, v, w;
		cin >> u >> v >> w;

		ans += w;

		if(w == 0) G[u].eb(v), G[v].eb(u);
		else e.eb(u, v, w);
	}

	for(int i=1; i<=n; i++) {
		if(G[i].size() == 1) {
			num[i] = 1;
			Dfs(i, i);
			break;
		}
	}

	for(auto i : e) {
		int u, v, w;
		tie(u, v, w) = i;

		if(num[u] > num[v]) swap(u, v);

		if(num[v] % 2 != num[u] % 2) continue;

		g[v].eb(u, w);
	}

	int mx = 0;
	for(int i=1; i<=n; i++) {
		for(auto j : g[i]) {
			dp[i] = max(dp[i], dp[j.fi-1] + j.se);
		}

		mx = max(dp[i], mx);
	}

	cout << ans - mx;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 416 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 640 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 640 KB Output isn't correct
2 Halted 0 ms 0 KB -