Pagini recente » Cod sursa (job #838244) | Cod sursa (job #175839) | Cod sursa (job #1633880) | Cod sursa (job #1528661) | Cod sursa (job #2882852)
#include <bits/stdc++.h>
using namespace std;
ifstream f("felinare.in");
ofstream g("felinare.out");
const int N = 8192;
int n, m, x, y, pereche[N], pereche2[N], felinare, stanga, dreapta; // lui pereche2 i se asociaza felinarele secundare
vector<int> c[N], c2[N];
bool viz[N];
int main(){
f >> n >> m;
for(int i = 0; i < m; i++){
f >> x >> y;
c[x].push_back(y);
c2[y].push_back(x);
}
f.close();
for(int i = 1; i <= n; i++){
if(c[i].size() == 0)
felinare++;
else
stanga++;
if(c2[i].size() == 0)
felinare++;
else
dreapta++;
}
g << felinare + max(stanga, dreapta) << '\n';
for(int i = 1; i <= n; i++){
int rep = 0;
if(c[i].size() == 0 || stanga > dreapta)
rep |= 1;
if(c2[i].size() == 0 || dreapta >= stanga)
rep |= 2;
g << rep << '\n';
}
g.close();
}