Created
January 7, 2017 01:56
-
-
Save dudelson/5ae979ff839d85f7390acf62a24d6e68 to your computer and use it in GitHub Desktop.
My solution for UVA 11926
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <bitset> | |
using namespace std; | |
#define maxn 1000001 | |
int n, m, s, t, r; | |
bitset<maxn> sch; | |
int main() { | |
ios_base::sync_with_stdio(false); | |
cin.tie(NULL); | |
while(cin >> n >> m, n||m) { | |
bool good = true; | |
sch.reset(); | |
for(int i=0; i<n; i++) { | |
cin >> s >> t; | |
if(!good) continue; | |
for(int j=s; j<t; j++) { | |
if(sch[j]) good = false; | |
else sch.set(j); | |
} | |
} | |
for(int i=0; i<m; i++) { | |
cin >> s >> t >> r; | |
if(!good) continue; | |
bool dobreak = false; | |
int ps = s, pt = t; | |
while(!dobreak && good) { | |
for(int j=ps; j<pt; j++) { | |
if(j >= maxn) { | |
dobreak = true; | |
break; | |
} else if(sch[j]) { | |
good = false; | |
break; | |
} else sch.set(j); | |
} | |
ps += r; pt += r; | |
} | |
} | |
cout << (good ? "NO " : "") << "CONFLICT\n"; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment