Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

求助,莫名RE

Posted by xyjg at 2019-02-22 17:37:47 on Problem 3038
#include<cstdio>
#include<iostream>
#include<queue>
#include<algorithm>
using namespace std;
struct cow{
	int s,e,n;
}d1[50005],d2[50005];
int c1,c2,n,k,c,x,y,ans;
bool cmp1(cow a,cow b){
	return a.s<b.s;
}
bool cmp2(cow a,cow b){
	return a.s>b.s;
}
priority_queue <int> q1;
priority_queue <int,vector<int>,greater<int> > q2;
int main(){
	cin>>k>>n>>c;
	for(int i=0;i<k;i++){
		cin>>x>>y;
		if(x<y){
			d1[++c1].s=x;
			d1[c1].e=y;
			cin>>d1[c1].n;
		}
		else{
			d2[++c2].s=x;
			d2[c2].e=y;
			cin>>d2[c2].n;
		}
	}
	sort(d1+1,d1+c1+1,cmp1);sort(d2+1,d2+c2+1,cmp2);
	for(int i=1;i<=c1;i++){
//		cout<<"q1	"<<q1.empty()<<endl;
		if(!q1.empty()){//就是在这里,q1.empty()一下就变成false
			cout<<q1.size();
			while(q1.top()<=d1[i].s){
				if(q1.empty())break;
				q1.pop();
				ans++;
			}
		}
		for(int i=0;i<d1[i].n;i++)q1.push(d1[i].e);
		while(q1.size()>c){
			q1.pop();
		}
	}
	while(!q1.empty()){
		q1.pop();
		ans++;
	}
	for(int i=1;i<=c2;i++){
		if(!q2.empty()){
			while(q2.top()<=d1[i].s){
				if(q2.empty())break;
				q2.pop();
				ans++;
			}
		}
		for(int i=0;i<d2[i].n;i++)q2.push(d2[i].e);
		while(q2.size()>c){
			q2.pop();
		}
	}
	while(!q2.empty()){
		q2.pop();
		ans++;
	}
	cout<<ans;
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator