-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2620.cpp
More file actions
55 lines (55 loc) · 742 Bytes
/
2620.cpp
File metadata and controls
55 lines (55 loc) · 742 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include<iostream>
#include<vector>
using namespace std;
struct zb{
int x,y;
};
int main(){
int m;
int x,y;
int i,j;
vector<struct zb> r;
int a[5001]={0};
struct zb z;
int no=0;
cin>>m>>x>>y;
i=j=0;
while(x||y){
if(y<=0||x>=m){cin>>x>>y;continue;}
if(x<=0){
if(y>j){
j=y;
i=x;
}}
else if(y>a[x])a[x]=y;
cin>>x>>y;
}
z.x=i;
z.y=j;
r.push_back(z);
i=1;
if(j==0)no=1;
else
while(j<m){
x=y=0;
while(i<=j){
if(a[i]>j)
if(a[i]>y){y=a[i];x=i;}
i++;
}
if(y==0){no=1;break;}
z.x=x;
z.y=y;
r.push_back(z);
i=j+1;
j=y;
}
if(no)cout<<"No solution"<<endl;
else {
cout<<r.size()<<endl;
for(i=0;i<r.size();i++){
cout<<r[i].x<<' '<<r[i].y<<endl;
}
}
return 0;
}