Skip to content

Instantly share code, notes, and snippets.

@rigibun
Last active December 10, 2015 07:58
Show Gist options
  • Save rigibun/4404767 to your computer and use it in GitHub Desktop.
Save rigibun/4404767 to your computer and use it in GitHub Desktop.
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
int main(void){
int a,b,c, t, n;
while(cin >> a >> b >> c, a + b + c !=0){
vector<int> h;
vector<int> p;
queue< vector<int> > que;
p.push_back(-1);
for(int i = 0; i < a + b + c; i++)
p.push_back(2);
cin >> n;
for(int i = 0; i < n; i++){
h.clear();
cin >> a >> b >> c >> t;
if(t == 1){
p[a] = p[b] = p[c] = 1;
}
else{
h.push_back(a);
h.push_back(b);
h.push_back(c);
h.push_back(t);
que.push(h);
}
}
while(!que.empty()){
a = que.front()[0];
b = que.front()[1];
c = que.front()[2];
if(p[a] == 2 && p[b] == 1 && p[c] == 1)
p[a] = 0;
if(p[a] == 1 && p[b] == 2 && p[c] == 1)
p[b] = 0;
if(p[a] == 1 && p[b] == 1 && p[c] == 2)
p[c] = 0;
que.pop();
}
for(int i = 1; i < p.size(); i++)
cout << p[i] << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment