답안 #277988

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
277988 2020-08-21T08:25:19 Z AKaan37 Magic Tree (CEOI19_magictree) C++17
0 / 100
1939 ms 36856 KB
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define mp make_pair
#define endl "\n"
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo inf = 1000000000000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 100005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t,dp[li][25];
int cev;
string s;
PII p[li];
vector<int> v[li];

inline void dfs(int node,int ata){
	for(int i=0;i<(int)v[node].size();i++){
		int go=v[node][i];
		if(go==ata)continue;
		dfs(go,node);
	}
	for(int i=p[node].fi;i<=k;i++){
		dp[node][i]=max(dp[node][i],(int)(dp[node][p[node].fi-1]+p[node].se));
	}
	for(int i=0;i<=k;i++){
		dp[ata][i]+=(dp[node][i]);
	}
}

int main(void){
	scanf("%d %d %d",&n,&m,&k);
	for(int i=2;i<=n;i++){
		int x;
		scanf("%d",&x);
		v[i].pb(x);
		v[x].pb(i);
	}
	for(int i=1;i<=m;i++){
		int x,y,z;
		scanf("%d %d %d",&x,&y,&z);
		p[x].fi=y;
		p[x].se=z;
	}
	dfs(1,0);
	printf("%d\n",dp[1][k]);
	return 0;
}

Compilation message

magictree.cpp: In function 'int main()':
magictree.cpp:50:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   50 |  scanf("%d %d %d",&n,&m,&k);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~
magictree.cpp:53:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   53 |   scanf("%d",&x);
      |   ~~~~~^~~~~~~~~
magictree.cpp:59:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   59 |   scanf("%d %d %d",&x,&y,&z);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Incorrect 2 ms 2688 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 94 ms 36856 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 2868 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 99 ms 17660 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Incorrect 2 ms 2688 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1939 ms 5992 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Incorrect 2 ms 2688 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Incorrect 2 ms 2688 KB Output isn't correct
3 Halted 0 ms 0 KB -