QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#400651#6692. Building CompanyxunxxxxWA 0ms3612kbC++231.0kb2024-04-27 14:40:022024-04-27 14:40:03

Judging History

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

  • [2024-04-27 14:40:03]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3612kb
  • [2024-04-27 14:40:02]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
int g,a,b,n,m,k,ans;
void solve()
{
	map<int,int>h;
	map<int,vector<pair<int,int>>>ne,re;
	cin>>g;
	while(g--)
	{
		cin>>a>>b;
		h[a]+=b;
	}
	cin>>n;
	vector<int>in(n+1);
	queue<int>q;
	for(int i=1;i<=n;i++)
	{
		cin>>m;
		while(m--)
		{
			cin>>a>>b;
			if(h[a]>=b) continue;
			ne[a].push_back({b,i});//ÐèÇó 
			in[i]++;//¶ÈÊý++ 
		}
		cin>>k;
		while(k--)
		{
			cin>>a>>b;
			re[i].push_back({a,b});//½±Àø 
		}
		if(in[i]==0) q.push(i);
	}

	ans=q.size();
	while(q.size())
	{
		int i=q.front();
		q.pop();
	//	cout<<i<<"\n";
		for(auto j:re[i]) 
		{
			a=j.first;
			b=j.second;
			h[a]+=b;
			for(auto k:ne[a])
			{
				if(k.second==0) continue;
				if(h[a]>=k.first)
				{
					in[k.second]--;
					k.second=0;
					if(!in[k.second]) 
					{
						q.push(k.second);
						ans++;
					}
				}
			}
		}
	}
	cout<<ans<<"\n";
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int T=1;
	//cin>>T;
	while(T--) solve();
} 

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3612kb

input:

2 2 1 1 2
5
1 3 1
0
2 1 1 2 1
2 3 2 2 1
3 1 5 2 3 3 4
1 2 5
3 2 1 1 1 3 4
1 1 3
0
1 3 2

output:

6

result:

wrong answer 1st numbers differ - expected: '4', found: '6'