-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBalancedSequence.cpp
More file actions
43 lines (41 loc) · 830 Bytes
/
BalancedSequence.cpp
File metadata and controls
43 lines (41 loc) · 830 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
#include <iostream>
#include <cstdlib>
using namespace std;
int compare(const void *a, const void *b) {
pair<int, int> *p1 = (pair<int, int>*)a;
pair<int, int> *p2 = (pair<int, int>*)b;
if (p1->first - p2->first > 0) {
return 1;
}
else if (p1->first - p2->first < 0) {
return -1;
}
else {
return p1->second - p2->second;
}
}
int main() {
int t;
cin >> t;
while (t--) {
int n, m;
cin >> n >> m;
int *arr = new int[n];
memset(arr, 1, sizeof(int)*n);
pair<int, int> *limits = new pair<int, int>[n];
for (int i = 0; i < m; i++) {
int l, r;
cin >> l >> r;
limits[i] = make_pair(l, r);
}
qsort(limits, sizeof(pair<int, int>), m, compare);
for (int i = 0; i < m; i++) {
int l = limits[i].first;
int r = limits[i].second;
if
for (int j = l; j <= r; j++) {
}
}
}
return 0;
}