QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#202224#6430. Monster HunterrsjCompile Error//C++141.4kb2023-10-05 20:53:022023-10-05 20:53:02

Judging History

你现在查看的是最新测评结果

  • [2023-10-05 20:53:02]
  • 评测
  • [2023-10-05 20:53:02]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N = 2077;
#define int long long
struct edge {
	int to;
	edge *nex;
}*head[N];
void add(int u,int v) {
	edge *cur=new edge;
	cur->to=v;
	cur->nex=head[u];
	head[u]=cur;
}
int f[N][N][2],siz[N],a[N],n; //1 Existed 0 Destructed
void chmin(int &x,int y) {
	x=min(x,y);
}
void dfs(int u) {
	siz[u]=1;
	for(edge *cur=head[u];cur;cur=cur->nex) {
		dfs(cur->to);
		siz[u]+=siz[cur->to];
	}
	f[u][1][1]=2*a[u];
	f[u][0][0]=0;
	int i,j;
	for(edge *cur=head[u];cur;cur=cur->nex) {
		for(i=siz[u];i>=0;i--) {
			for(j=siz[cur->to];j>0;j--) {
				chmin(f[u][i+j][1],f[u][i][1]+min(f[cur->to][j][1],f[cur->to][j][0]));
				chmin(f[u][i+j][0],f[u][i][0]+min(f[cur->to][j][1]-a[cur->to],f[cur->to][j][0]));
			}
		}
		siz[u]+=siz[cur->to];
	}
}
int count=0,evil=0;
int fa[N];
void get() {
	int i,j,x;
	cin>>n;
	for(i=1;i<=n;i++) head[i]=0;
	for(i=0;i<=n;i++) for(j=0;j<=n;j++) f[i][j][0]=f[i][j][1]=1e16;
	for(i=2;i<=n;i++) cin>>fa[i],add(fa[i],i);
	for(i=1;i<=n;i++) cin>>a[i];
	count++;
	if(evil&&count==9) {
		cout<<n<<endl;
		for(i=1;i<=n;i++) cout<<fa[i]<<" ";
		for(i=1;i<=n;i++) cout<<a[i]<<" ";
	}
	dfs(1);
	if(evil) for(i=n;i>=0;i--) cout<<min(f[1][i][1]-a[1],f[1][i][0])<<" \n"[i==0]; 
}
signed main() {
	//freopen("1.in","r",stdin);
	int T; cin>>T; if(T==179) evil=1;
	while(T--) get();
	return 0;
} 

Details

answer.code: In function ‘void get()’:
answer.code:47:9: error: reference to ‘count’ is ambiguous
   47 |         count++;
      |         ^~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from answer.code:1:
/usr/include/c++/11/bits/stl_algo.h:4059:5: note: candidates are: ‘template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)’
 4059 |     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
      |     ^~~~~
answer.code:38:5: note:                 ‘long long int count’
   38 | int count=0,evil=0;
      |     ^~~~~
answer.code:48:18: error: reference to ‘count’ is ambiguous
   48 |         if(evil&&count==9) {
      |                  ^~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from answer.code:1:
/usr/include/c++/11/bits/stl_algo.h:4059:5: note: candidates are: ‘template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)’
 4059 |     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
      |     ^~~~~
answer.code:38:5: note:                 ‘long long int count’
   38 | int count=0,evil=0;
      |     ^~~~~