답안 #135772

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
135772 2019-07-24T10:53:14 Z MvC Training (IOI07_training) C++11
10 / 100
5 ms 760 KB
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include<bits/stdc++.h>
//#include "job.h"
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=1e3+50;
const ll mod=1e9+7;
using namespace std;
int n,m,h[nmax],x,y,z,rs,sm,i,j,f[nmax];
vector<pair<int,int> >a[nmax],g[nmax];
void dfs(int x,int p)
{
	h[x]=h[p]+1;
	for(int i=0;i<a[x].size();i++)
	{
		int y=a[x][i].fr,z=a[x][i].sc;
		if(y==p || z)continue;
		dfs(y,x);
	}
}
void rec(int x,int p)
{
	for(int i=0;i<g[x].size();i++)
	{
		int y=g[x][i].fr,z=g[x][i].sc;
		if(y==p || z)continue;
		rec(y,x);
	}
	for(int i=0;i<g[x].size();i++)
	{
		int y=g[x][i].fr,z=g[x][i].sc;
		if(h[y]>h[x])continue;
		f[y]=max(f[y],f[x]+z);
	}
	rs=max(rs,f[x]);
}
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n>>m;
	for(i=1;i<=m;i++)
	{
		cin>>x>>y>>z;
		a[x].pb(mkp(y,z));
		a[y].pb(mkp(x,z));
		sm+=z;
	}
	dfs(1,0);
	for(i=1;i<=n;i++)
	{
		for(j=0;j<a[i].size();j++)
		{
			y=a[i][j].fr,z=a[i][j].sc;
			if(!z || (h[i]&1)==(h[y]&1))g[i].pb(a[i][j]);
		}
	}
	rec(1,0);
	cout<<sm-rs<<endl;
    return 0;
}

Compilation message

training.cpp:2:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("O3")
 
training.cpp:3:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("unroll-loops")
 
training.cpp: In function 'void dfs(int, int)':
training.cpp:27:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<a[x].size();i++)
              ~^~~~~~~~~~~~
training.cpp: In function 'void rec(int, int)':
training.cpp:36:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<g[x].size();i++)
              ~^~~~~~~~~~~~
training.cpp:42:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<g[x].size();i++)
              ~^~~~~~~~~~~~
training.cpp: In function 'int main()':
training.cpp:67:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(j=0;j<a[i].size();j++)
           ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 632 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 476 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 676 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 760 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 760 KB Output isn't correct
2 Halted 0 ms 0 KB -