QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#557574#8222. 投票游戏Kevin5307Compile Error//C++231.7kb2024-09-11 10:20:032024-09-11 10:20:09

Judging History

This is the latest submission verdict.

  • [2024-09-11 10:20:09]
  • Judged
  • [2024-09-11 10:20:03]
  • Submitted

answer

//Author: Kevin
#include<bits/stdc++.h>
//#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned ll
#define pb emplace_back
#define mp make_pair
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
#define srt(x) sort(ALL(x))
#define rev(x) reverse(ALL(x))
#define rsrt(x) sort(rALL(x))
#define sz(x) (int)(x.size())
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define lb(v,x) (int)(lower_bound(ALL(v),x)-v.begin())
#define ub(v,x) (int)(upper_bound(ALL(v),x)-v.begin())
#define uni(v) v.resize(unique(ALL(v))-v.begin())
#define longer __int128_t
void die(string S){puts(S.c_str());exit(0);}
int p[200200];
ll a[200200],b[200200];
ll tmp[200200];
int kill[200200];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,q;
	cin>>n>>q;
	for(int i=2;i<=n;i++)
		cin>>p[i];
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
		cin>>b[i];
	while(q--)
	{
		int op;
		cin>>op;
		if(op==1)
		{
			int x,y,z;
			cin>>x>>y>>z;
			a[x]=y;
			b[x]=z;
		}
		else
		{
			int c,d;
			cin>>c>>d;
			memset(tmp,0,sizeof(ll)*(n+5));
			memset(kill,0,sizeof(int)*(n+5));
			for(int i=1;i<=n;i++)
				tmp[i]=a[i];
			for(int i=2;i<=n;i++)
				tmp[p[i]]+=b[i];
			priority_queue<pair<ll,int>> pq;
			for(int i=1;i<=n;i++)
				pq.emplace(tmp[i],i);
			int ans=0;
			while(!pq.empty())
			{
				ll V=pq.top().first;
				int u=pq.top().second;
				pq.pop();
				if(tmp[u]!=V||kill[u]) continue;
				if(u==c)
					break;
				if(u==d)
				{
					ans=1;
					break;
				}
				kill[u]=1;
				if(p[u]&&!kill[p[u]])
				{
					tmp[p[u]]-=b[u];
					pq.emplace(tmp[p[u]],p[u]);
				}
			}
			cout<<ans<<'\n';
		}
	}
	return 0;
}

详细

answer.code:25:16: error: ‘int kill [200200]’ redeclared as different kind of entity
   25 | int kill[200200];
      |                ^
In file included from /usr/include/c++/13/csignal:42,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:116,
                 from answer.code:2:
/usr/include/signal.h:112:12: note: previous declaration ‘int kill(__pid_t, int)’
  112 | extern int kill (__pid_t __pid, int __sig) __THROW;
      |            ^~~~
answer.code: In function ‘int main()’:
answer.code:55:32: error: invalid conversion from ‘int (*)(__pid_t, int) noexcept’ {aka ‘int (*)(int, int) noexcept’} to ‘void*’ [-fpermissive]
   55 |                         memset(kill,0,sizeof(int)*(n+5));
      |                                ^~~~
      |                                |
      |                                int (*)(__pid_t, int) noexcept {aka int (*)(int, int) noexcept}
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/c++config.h:679,
                 from /usr/include/c++/13/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:33:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:59:1: note:   initializing argument 1 of ‘void* memset(void*, int, size_t)’
   59 | __NTH (memset (void *__dest, int __ch, size_t __len))
      | ^~~~~
answer.code:69:53: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   69 |                                 if(tmp[u]!=V||kill[u]) continue;
      |                                                     ^
answer.code:77:39: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   77 |                                 kill[u]=1;
      |                                       ^
answer.code:77:40: error: assignment of read-only location ‘*(kill + ((sizetype)u))’
   77 |                                 kill[u]=1;
      |                                 ~~~~~~~^~
answer.code:78:52: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   78 |                                 if(p[u]&&!kill[p[u]])
      |                                                    ^