답안 #952148

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
952148 2024-03-23T06:42:33 Z vjudge1 Museum (CEOI17_museum) C++17
0 / 100
287 ms 783984 KB
#pragma GCC optimize(3)
#pragma GCC target("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
int n,k,x,tim[10005],dp[10001][10001][2],son[10005];
struct l{
	int tar,wei;
};
vector<l>q[10005];
void dfs(int now,int fa){
	if(clock()>=2950){
		return ;
	} 
	son[now]=1;
	dp[now][0][0]=0;
	dp[now][0][1]=0;
	dp[now][1][1]=0;
	dp[now][1][0]=0;
	for(int i=0;i<q[now].size();i++){
		if(q[now][i].tar==fa){
			continue;
		} 
		dfs(q[now][i].tar,now);
		son[now]+=son[q[now][i].tar];
		for(int j=min(k,son[now]);j>=2;j--){
			for(int l=0;l<=min(j,son[q[now][i].tar]);l++){
				dp[now][j][0]=min(dp[now][j][0],dp[now][j-l][0]+dp[q[now][i].tar][l][0]+2*q[now][i].wei);
				dp[now][j][1]=min(dp[now][j][1],dp[now][j-l][0]+dp[q[now][i].tar][l][1]+q[now][i].wei);
				dp[now][j][1]=min(dp[now][j][1],dp[now][j-l][1]+dp[q[now][i].tar][l][0]+2*q[now][i].wei);
			}
		//	cout<<now<<" "<<j<<" "<<dp[now][j][0]<<" "<<dp[now][j][1]<<endl;
		}
	}
}
int main(){
//	freopen("museum.in","r",stdin);
//	freopen("museum.out","w",stdout);
	memset(dp,0x3f,sizeof(dp));
	scanf("%d%d%d",&n,&k,&x);
	for(int i=1;i<n;i++){
		int u,v,w;
		scanf("%d%d%d",&u,&v,&w);
		q[u].push_back({v,w});
		q[v].push_back({u,w});
	}
	dfs(x,0);
	printf("%d",min(dp[x][k][0],dp[x][k][1]));
	return 0;
}

Compilation message

museum.cpp:22:39: warning: bad option '-fwhole-program' to pragma 'optimize' [-Wpragmas]
   22 | #pragma GCC optimize("-fwhole-program")
      |                                       ^
museum.cpp:29:41: warning: bad option '-fstrict-overflow' to pragma 'optimize' [-Wpragmas]
   29 | #pragma GCC optimize("-fstrict-overflow")
      |                                         ^
museum.cpp:31:41: warning: bad option '-fcse-skip-blocks' to pragma 'optimize' [-Wpragmas]
   31 | #pragma GCC optimize("-fcse-skip-blocks")
      |                                         ^
museum.cpp:45:51: warning: bad option '-funsafe-loop-optimizations' to pragma 'optimize' [-Wpragmas]
   45 | #pragma GCC optimize("-funsafe-loop-optimizations")
      |                                                   ^
museum.cpp:56:24: warning: bad option '-fwhole-program' to attribute 'optimize' [-Wattributes]
   56 | void dfs(int now,int fa){
      |                        ^
museum.cpp:56:24: warning: bad option '-fstrict-overflow' to attribute 'optimize' [-Wattributes]
museum.cpp:56:24: warning: bad option '-fcse-skip-blocks' to attribute 'optimize' [-Wattributes]
museum.cpp:56:24: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
museum.cpp: In function 'void dfs(int, int)':
museum.cpp:65:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<l>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |  for(int i=0;i<q[now].size();i++){
      |              ~^~~~~~~~~~~~~~
museum.cpp: At global scope:
museum.cpp:81:10: warning: bad option '-fwhole-program' to attribute 'optimize' [-Wattributes]
   81 | int main(){
      |          ^
museum.cpp:81:10: warning: bad option '-fstrict-overflow' to attribute 'optimize' [-Wattributes]
museum.cpp:81:10: warning: bad option '-fcse-skip-blocks' to attribute 'optimize' [-Wattributes]
museum.cpp:81:10: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
museum.cpp: In function 'int main()':
museum.cpp:85:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   85 |  scanf("%d%d%d",&n,&k,&x);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~
museum.cpp:88:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   88 |   scanf("%d%d%d",&u,&v,&w);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 287 ms 783504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 222 ms 783984 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 222 ms 783984 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 287 ms 783504 KB Output isn't correct
2 Halted 0 ms 0 KB -