-
Notifications
You must be signed in to change notification settings - Fork 0
/
revegate.cpp
50 lines (47 loc) · 1.29 KB
/
revegate.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <array>
#include <iterator>
#include <tuple>
#include <unordered_map>
using namespace std;
int main() {
freopen("revegetate.in", "r", stdin);
freopen("revegetate.out", "w", stdout);
int N, M; cin >> N >> M;
vector<pair<int, int>> favorites;
for (int i=0; i<M; i++) {
int first, second; cin >> first >> second;
favorites.emplace_back(first, second);
}
int pastures[N];
for (int i=0; i<N; i++) {
if (i == 0) {
pastures[i] = 1;
} else {
map<int, bool> forbidden;
forbidden[1] =false; forbidden[2] = false; forbidden[3] = false; forbidden[4] = false;
for (int j=0; j<i; j++) {
for (auto pair: favorites) {
if (pair == make_pair(i+1, j+1) || pair == make_pair(j+1, i+1)) {
forbidden[pastures[j]] = true;
}
}
}
for (int k=1; k<5; k++) {
if (!forbidden[k]) {
pastures[i] = k;
break;
}
}
}
}
for (auto pasture: pastures) {
cout << pasture;
}
}