QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#487678#7684. Sweet SugarSATSKYCompile Error//C++141.6kb2024-07-23 06:41:582024-07-23 06:41:58

Judging History

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

  • [2024-07-23 06:41:58]
  • 评测
  • [2024-07-23 06:41:58]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;using ll=long long;using ld=long double;using pii=pair<int,int>;
const int M=998244353,P=20;const ll inf=1e17;const double eps=1e-10;
int xt,tc;
bool o;
struct S
{	
	int n,K,res=0;vector<vector<int>>es;
	vector<int>val,lit;
	void ini()
	{
		cin>>n>>K;val.resize(n+1,0);lit=val;for(int i=1;i<=n;i++)cin>>val[i];
		if(o)
		{
			cout<<n<<' '<<k<<'\n';
			for(int i=1;i<=n;i++)cout<<val[i]<<" \n"[i==n];
		}
		es.resize(n+1);
		for(int i=1,u,v;i<n;i++)
		{
			cin>>u>>v,es[u].push_back(v),es[v].push_back(u);
			if(o)
			{
				cout<<u<<' '<<v<<'\n';
			}
		}
	}
	struct Ks
	{
		int sum=0,sp=M;//min_rt1_trs
	};
	Ks mg(Ks U,Ks D)
	{
		return Ks{U.sum+D.sum,min(U.sp,D.sp)};
	}
	Ks spr(int x,int lst)
	{
		lit[x]=1;Ks A={0,M};int d=0;
		for(auto&k:es[x])if(!lit[k])
		{
			auto p=spr(k,x);
			A=mg(A,p);d++;
		}
		if(d==1&&val[x]==1)
		{
			if(A.sum+1>=K){res++;return Ks{0,0};}
		}
		if(val[x]==1)A={A.sum+1,min(A.sp,A.sum+1)};
		else A={A.sum+val[x],A.sp};
		if(A.sum>=K)
		{
			if((A.sum-K)%2==0){res++;return Ks{0,0};}
			else if(A.sum-A.sp>=K){res++;return Ks{0,0};}
		}
		return A;
	}
	void solve()
	{
		for(int i=1;i<=n;i++)if(!lit[i])spr(i,0);
		if(t<=1000)cout<<res<<'\n';
	}
};
void precal()
{

}
int main()
{
	//freopen("1.in","r",stdin);
	//cout<<fixed<<setprecision(12);
	ios::sync_with_stdio(0);cin.tie(0);precal();
	int t=1;cin>>t;xt=t;
	//clock_t a=clock();
	while(t--){tc++;o=(tc==32);S SS;SS.ini();SS.solve();}
	//cout<<"Time:"<<double(clock()-a)<<'\n';
}
/*

*/

详细

answer.code: In member function ‘void S::ini()’:
answer.code:15:39: error: ‘k’ was not declared in this scope
   15 |                         cout<<n<<' '<<k<<'\n';
      |                                       ^
answer.code: In member function ‘void S::solve()’:
answer.code:60:20: error: ‘t’ was not declared in this scope; did you mean ‘xt’?
   60 |                 if(t<=1000)cout<<res<<'\n';
      |                    ^
      |                    xt