153992025-02-19 11:38:27mateÁdám és Éva együttcpp17Time limit exceeded 26/50500ms12660 KiB
#include <bits/stdc++.h>
#include <cstdint>
#include <vector>
using namespace std;

int main() {
    ios::sync_with_stdio(0); cin.tie(0), cout.tie(0);
	int n; cin >> n;
    vector<bool> w(n+1,1);
    int a ,e; cin >> a;
    int b,c;
    while(a--){
        cin >> b >> c;
        for(int i = b; i < c; i++){
            w[i] = 0;
        }
    }
    cin >> e;
    bool igaz = 0;
    int kezd = 0;
    vector <pair<int,int>> ans;
    while(e--){
        igaz = 0;
        cin >> b >> c;
        for(int i = b; i < c; i++){
            if(w[i] == 0 && !igaz){
                igaz = 1;
                kezd = i;
            }
            cerr << i << ' ';

            if(w[i] > 0 && igaz){
                ans.push_back({kezd,i});
                igaz = 0;
            }
            if(i == c-1 && igaz){
                ans.push_back({kezd,i+1});
                igaz = 0;
            }
            //v[i] = 0;
        }
    }
    
    
    cout << ans.size() << '\n';
    for(auto x : ans){
        cout << x.first << ' ' << x.second << '\n';
    }
}
SubtaskSumTestVerdictTimeMemory
base26/50
1Accepted0/01ms316 KiB
2Accepted0/032ms316 KiB
3Accepted2/21ms316 KiB
4Accepted2/21ms316 KiB
5Accepted2/21ms316 KiB
6Accepted2/21ms316 KiB
7Accepted2/21ms316 KiB
8Accepted2/21ms316 KiB
9Accepted2/21ms316 KiB
10Accepted2/22ms420 KiB
11Accepted2/26ms420 KiB
12Accepted2/227ms420 KiB
13Accepted2/232ms436 KiB
14Accepted2/235ms428 KiB
15Accepted2/2195ms476 KiB
16Time limit exceeded0/2486ms12656 KiB
17Time limit exceeded0/3500ms12656 KiB
18Time limit exceeded0/3500ms11316 KiB
19Time limit exceeded0/4483ms11828 KiB
20Time limit exceeded0/4483ms12340 KiB
21Time limit exceeded0/4500ms12660 KiB
22Time limit exceeded0/4500ms12596 KiB