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

## 纪念一下

Posted by 983543692 at 2016-06-07 10:49:15 on Problem 3190
```#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
const int maxn=1e6+7;
struct cow{
int l,r;
int num;
int stalk;
};
class cmp1{
public:
bool operator()(cow x,cow y)
{
return x.l>y.l;
}
};
class cmp2{
public:
bool operator()(cow x,cow y)
{
return x.r>y.r;
}
};
int main()
{
int n;scanf("%d",&n);cow tmp;
priority_queue<cow,vector<cow>,cmp2> q2;
priority_queue<cow,vector<cow>,cmp1> q1;
vector<int> cctime;
vector<cow> mycow(n+1);vector<int> number(n+1);
for(int i=1;i<=n;i++)scanf("%d%d",&mycow[i].l,&mycow[i].r),cctime.push_back(mycow[i].l),cctime.push_back(mycow[i].r+1),mycow[i].num=i,q1.push(mycow[i]);
sort(cctime.begin(),cctime.end());
cctime.erase(unique(cctime.begin(),cctime.end()),cctime.end());
int cnt=0;
queue<int> stall;
int maxv=0;
for(int j=0;j<cctime.size();j++)
{
int i=cctime[j];
while(!q2.empty()&&i>q2.top().r)
{
stall.push(q2.top().stalk);
//	cout<<i<<"*****stall**"<<q2.top().stalk<<"******"<<q2.top().l<<"***outout**"<<q2.top().r<<endl;
number[q2.top().num]=q2.top().stalk;
q2.pop();
}
while(!q1.empty()&&i>=q1.top().l)
{
if(stall.empty())++cnt,stall.push(cnt);
cow tmp=q1.top();tmp.stalk=stall.front();
//	cout<<i<<"************intint******stall****"<<tmp.stalk<<"****************"<<tmp.l<<"   "<<tmp.r<<endl;
q2.push(tmp);q1.pop();stall.pop();
}
}
cout<<cnt<<endl;
for(int i=1;i<=n;i++)cout<<number[i]<<endl;
} ```

Followed by: