Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <vector>
- using namespace std;
- int n;
- vector<int> v[202020];
- int q[202020];
- int h[202020];
- int main() {
- srand(1337);
- cin >> n;
- for (int i = 0; i < 5; i++) {
- int c;
- cin >> c;
- for (int j = 0; j < c; j++) {
- int a, b;
- cin >> a >> b;
- bool ok = true;
- for (int k = 0; k < v[a].size(); k++) {
- if (v[a][k] == b) ok = false;
- }
- if (!ok) continue;
- v[a].push_back(b);
- v[b].push_back(a);
- }
- }
- for (int i = 1; i <= n; i++) q[i] = rand()%2;
- for (int i = 1; i <= n; i++) h[i] = i;
- for (int i = 1; i <= n; i++) {
- swap(h[i], h[i+rand()%(n-i+1)]);
- }
- while (true) {
- bool ok = true;
- for (int x = 1; x <= n; x++) {
- int i = h[x];
- int a = q[i];
- int z = 0;
- for (int j = 0; j < v[i].size(); j++) {
- if (q[v[i][j]] == a) z++;
- }
- if (z <= 2) continue;
- ok = false;
- q[i] = 1-q[i];
- }
- if (ok) break;
- }
- for (int i = 1; i <= n; i++) {
- if (q[i] == 0) cout << "A";
- else cout << "B";
- }
- cout << "\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement