Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- struct A{
- int date, open, fri;
- };
- int main()
- {
- int n, x = 0, f = 0, y = 0;
- cin >> n;
- vector <A> c(n * 2);
- for (int i = 0; i < n * 2; i++){
- cin >> c[x].date;
- c[x].fri = y;
- if(f == 0) {
- c[x].open = 0;
- f++;
- }
- else{
- c[x].open = 1;
- f--;
- }
- x++;
- if(i % 2 != 0 && i != 0) y++;
- }
- x--;
- sort(c.begin(), c.end());
- for (int i = 0; i < x + 1; i++) {
- cout << c[i].date << ' ' << c[i].open << ' ' << c[i].fri << endl;
- }
- vector <pair <int, int> > r(n);
- for(int i = 0; i < x; i++){
- if(c[i - 1].fri == c[i + 2].fri && c[i].fri == c[i + 1].fri){
- r[c[i].fri].first = -1;
- r[c[i].fri].second = -1;
- }
- if(c[i].open == 1 && r[c[i].fri].second == 0){
- r[c[i].fri].second = c[i].date;
- }
- if(c[i].open == 0 && c[i - 1].open == 0 && r[c[i - 1].fri].second == 0){
- r[c[i - 1].fri].second = c[i].date;
- }
- if(c[i].open == 0 && r[c[i].fri].first == 0){
- r[c[i].fri].first = c[i].date;
- }
- }
- for(int i = 0; i < n; i++){
- cout << r[i].first << ' ' << r[i].second << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement