QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#209017 | #6430. Monster Hunter | HT008 | Compile Error | / | / | C++14 | 1.2kb | 2023-10-10 02:33:23 | 2023-10-10 02:33:23 |
Judging History
answer
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#define int long long
using namespace std;
const int maxm=2e4+100;
vector<int> edge[maxm];
int dp[maxm][maxm][2],val[maxm],siz[maxm];
int n;
void dfs(int now)
{
siz[now]=1;
dp[now][0][0]=0;
dp[now][1][1]=val[now];
for(int i=0;i<edge[now].size();i++)
{
int v=edge[now][i];
dfs(v);
for(int j=siz[now];j>=0;j--)
for(int k=siz[v];k>=0;k--)
{
dp[now][j+k][0]=min(dp[now][j+k][0],dp[now][j][0]+min(dp[v][k][0],dp[v][k][1]));
dp[now][j+k][1]=min(dp[now][j+k][1],dp[now][j][1]+min(dp[v][k][0],dp[v][k][1]+val[v]));
}
siz[now]+=siz[v];
}
}
void init()
{
for(int i=0;i<=n;i++)
for(int j=0;j<=n;j++)
dp[i][j][0]=dp[i][j][1]=1e18;
for(int i=1;i<=n;i++)
edge[i].clear(),siz[i]=0;
}
void work()
{
scanf("%lld",&n);
init();
for(int i=2;i<=n;i++)
{
int x;
scanf("%lld",&x);
edge[x].push_back(i);
}
for(int i=1;i<=n;i++)
scanf("%lld",&val[i]);
dfs(1);
for(int i=n;i>=0;i--)
printf("%lld ",min(dp[1][i][1],dp[1][i][0]));
puts("");
}
signed main()
{
int t;
scanf("%d",&t);
while(t--) work();
return 0;
}
Details
answer.code: In function ‘int main()’: answer.code:59:17: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘long long int*’ [-Wformat=] 59 | scanf("%d",&t); | ~^ ~~ | | | | | long long int* | int* | %lld answer.code: In function ‘void work()’: answer.code:41:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 41 | scanf("%lld",&n); | ~~~~~^~~~~~~~~~~ answer.code:46:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 46 | scanf("%lld",&x); | ~~~~~^~~~~~~~~~~ answer.code:50:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 50 | scanf("%lld",&val[i]); | ~~~~~^~~~~~~~~~~~~~~~ answer.code: In function ‘int main()’: answer.code:59:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 59 | scanf("%d",&t); | ~~~~~^~~~~~~~~ /tmp/ccSSrDoM.o: in function `__tcf_0': answer.code:(.text+0x9): relocation truncated to fit: R_X86_64_PC32 against symbol `edge' defined in .bss section in /tmp/ccSSrDoM.o /tmp/ccSSrDoM.o: in function `dfs(long long)': answer.code:(.text+0x79): relocation truncated to fit: R_X86_64_PC32 against symbol `edge' defined in .bss section in /tmp/ccSSrDoM.o /tmp/ccSSrDoM.o: in function `init()': answer.code:(.text+0x4da): relocation truncated to fit: R_X86_64_PC32 against symbol `edge' defined in .bss section in /tmp/ccSSrDoM.o answer.code:(.text+0x534): relocation truncated to fit: R_X86_64_PC32 against symbol `edge' defined in .bss section in /tmp/ccSSrDoM.o /tmp/ccSSrDoM.o: in function `work()': answer.code:(.text+0x7a3): relocation truncated to fit: R_X86_64_PC32 against symbol `edge' defined in .bss section in /tmp/ccSSrDoM.o answer.code:(.text+0x7fe): relocation truncated to fit: R_X86_64_PC32 against symbol `edge' defined in .bss section in /tmp/ccSSrDoM.o answer.code:(.text+0x93a): relocation truncated to fit: R_X86_64_PC32 against symbol `edge' defined in .bss section in /tmp/ccSSrDoM.o answer.code:(.text+0x9d3): relocation truncated to fit: R_X86_64_PC32 against symbol `edge' defined in .bss section in /tmp/ccSSrDoM.o answer.code:(.text+0x9f7): relocation truncated to fit: R_X86_64_PC32 against symbol `edge' defined in .bss section in /tmp/ccSSrDoM.o /tmp/ccSSrDoM.o: in function `_GLOBAL__sub_I_edge': answer.code:(.text.startup+0x81): relocation truncated to fit: R_X86_64_PC32 against `.bss' answer.code:(.text.startup+0xa6): additional relocation overflows omitted from the output collect2: error: ld returned 1 exit status