QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#400651 | #6692. Building Company | xunxxxx | WA | 0ms | 3612kb | C++23 | 1.0kb | 2024-04-27 14:40:02 | 2024-04-27 14:40:03 |
Judging History
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'