QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#225026#6406. Stage Clearucup-team1004WA 0ms3740kbC++141.3kb2023-10-23 21:06:092023-10-23 21:06:09

Judging History

This is the latest submission verdict.

  • [2024-08-15 21:05:17]
  • hack成功,自动添加数据
  • (/hack/778)
  • [2023-10-23 21:06:09]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3740kb
  • [2023-10-23 21:06:09]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<typename T>
ostream& operator << (ostream &out,const vector<T> &x){
	if(x.empty())return out<<"[]";
	out<<'['<<x[0];
	for(int i=1,len=x.size();i<len;i++)out<<','<<x[i];
	return out<<']';
}
template<typename T>
vector<T> ary(const T *a,int l,int r){
	return vector<T>{a+l,a+1+r};
}
template<typename T>
void debug(T x){
	cerr<<x<<endl;
}
template<typename T,typename ... S>
void debug(T x,S...y){
	cerr<<x<<' ',debug(y...);
}
const int N=80;
int n,m;
vector<int>to[N];
struct zj{
	ll a,b;
	bool operator < (const zj &x)const{
		int p=a<=b,q=x.a<=x.b;
		if(p^q)return p;
		else if(p)return a<x.a;
		else return b>x.b;
	}
	zj operator + (const zj &x)const{
		if(b<x.a)return {a-b+x.a,x.b};
		else return {a,b-x.a+x.b};
	}
}a[N];
priority_queue<pair<zj,int>,vector<pair<zj,int> >,greater<pair<zj,int> > >q;
int vis[N];
int main(){
	// freopen(".in","r",stdin);
	// freopen(".out","w",stdout);
	cin>>n>>m;
	for(int i=2;i<=n;i++)cin>>a[i].a>>a[i].b;
	for(int u,v;m--;){
		cin>>u>>v,to[u].push_back(v);
	}
	q.push({a[1],1}),vis[1]=1;
	zj ans={0,0};
	for(int u;!q.empty();){
		u=q.top().second,q.pop();
		ans=ans+a[u];
		for(int v:to[u]){
			if(!vis[v]){
				q.push({a[v],v}),vis[v]=1;
			}
		}
	}
	cout<<ans.a<<endl;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4 4
4 2
5 3
2 6
1 2
1 3
2 4
3 4

output:

5

result:

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