Skip to content

Instantly share code, notes, and snippets.

@dudelson
Created January 7, 2017 01:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dudelson/5ae979ff839d85f7390acf62a24d6e68 to your computer and use it in GitHub Desktop.
Save dudelson/5ae979ff839d85f7390acf62a24d6e68 to your computer and use it in GitHub Desktop.
My solution for UVA 11926
#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