-
Notifications
You must be signed in to change notification settings - Fork 1
/
uva_11926 Multitasking.cpp
46 lines (44 loc) · 1.2 KB
/
uva_11926 Multitasking.cpp
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
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;
int main() {
// 11:15
int n = 0, m = 0;
while (cin >> n) {
cin >> m;
if (n == 0 && m == 0) break;
vector<pair<int, int>> vec;
while (n--) {
int l, r;
cin >> l >> r;
vec.emplace_back(pair<int, int> (l, r));
}
while (m--) {
int l, r, interval;
cin >> l >> r >> interval;
while (r <= 2000000) { // duplicate event as much as neeeded
vec.emplace_back(pair<int, int> (l, r));
l += interval;
r += interval;
}
}
sort(vec.begin(), vec.end());
bool conflict = false;
for (int i = 0; i + 1 < vec.size(); i++) {
if (vec[i].second > vec[i + 1].first) {
conflict = true;
break;
}
if (vec[i].first > 1000000) break;
}
cout << (conflict ? "CONFLICT" : "NO CONFLICT") << endl;
}
return 0;
}