Pagini recente » Cod sursa (job #2961345) | Cod sursa (job #1881492) | Cod sursa (job #2191729) | Cod sursa (job #1933906) | Cod sursa (job #2815024)
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;
ifstream f("circulatie.in");
ofstream g("circulatie.out");
const int maxn = 1e5+5;
int n;
vector <int> v[maxn];
int a[maxn][4];
int u[maxn], l[maxn], r[maxn];
int viz[maxn];
bool check(int x) {
if(viz[x] == 1)
return false;
viz[x] = 1;
int i;
i = 0;
for(auto u : v[x]) {
i ++;
}
i = 0;
return false;
}
int main()
{
int x, y, i;
f >> n;
for(i = 1; i <= 3 * n; i ++) {
f >> x >> y;
v[x].push_back(y);
v[y].push_back(x);
}
ok = true;
while(ok == true) {
ok = false;
memset(viz, 0, sizeof(viz));
for(i = 1; i <= n; i ++) {
if(u[i] != 3 || l[i] != 0) {
if(check(i) == true) {
ok = true;
}
}
}
}
f.close(); g.close();
return 0;
}