-
Notifications
You must be signed in to change notification settings - Fork 0
/
uva11972.cpp
63 lines (48 loc) · 1.54 KB
/
uva11972.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <iostream>
#include <cstring>
#include <bitset>
#include <fstream>
using namespace std;
const int maxSize = 1000000;
bitset<maxSize> calender;
int main(){
int n, m;
while(cin>>n>>m && !(n == 0 && m == 0)){
calender.reset();
pair<int, int> constant;
pair<pair<int, int>, int> repeated;
bool conflict = false;
for(int i = 0; i < n; i++){
cin>>constant.first;
cin>>constant.second;
//fill calender array:
for(int i = constant.first; i < constant.second && !conflict; i++){
if(calender.test(i)){
conflict = true;
}else{
calender.set(i);
}
}
}
for(int i = 0; i < m; i++){
cin>>repeated.first.first;
cin>>repeated.first.second;
cin>>repeated.second;
//fill calender array:
while(repeated.first.first < maxSize && !conflict){
for(int i = repeated.first.first; i < repeated.first.second && i < maxSize && !conflict; i++){
if(calender.test(i)){
conflict = true;
}else{
calender.set(i);
}
}
repeated.first.first += repeated.second;
repeated.first.second += repeated.second;
}
}
cout<<(conflict ? "CONFLICT" : "NO CONFLICT")<<endl;
}
return 0;
}
// ds 28 solved in 1h (tfnynt nzrb)