| Task: | Coloring |
| Sender: | Makkara |
| Submission time: | 2025-11-08 13:55:58 +0200 |
| Language: | C++ (C++17) |
| Status: | READY |
| Result: | WRONG ANSWER |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.00 s | details |
| #2 | ACCEPTED | 0.27 s | details |
| #3 | ACCEPTED | 0.26 s | details |
| #4 | ACCEPTED | 0.27 s | details |
| #5 | ACCEPTED | 0.00 s | details |
| #6 | ACCEPTED | 0.00 s | details |
| #7 | ACCEPTED | 0.00 s | details |
| #8 | ACCEPTED | 0.00 s | details |
| #9 | WRONG ANSWER | 0.01 s | details |
| #10 | WRONG ANSWER | 0.02 s | details |
| #11 | WRONG ANSWER | 0.20 s | details |
| #12 | WRONG ANSWER | 0.42 s | details |
| #13 | WRONG ANSWER | 0.42 s | details |
| #14 | WRONG ANSWER | 0.42 s | details |
| #15 | ACCEPTED | 0.00 s | details |
| #16 | ACCEPTED | 0.21 s | details |
| #17 | ACCEPTED | 0.37 s | details |
| #18 | ACCEPTED | 0.00 s | details |
| #19 | ACCEPTED | 0.00 s | details |
| #20 | ACCEPTED | 0.26 s | details |
| #21 | ACCEPTED | 0.00 s | details |
| #22 | ACCEPTED | 0.00 s | details |
| #23 | ACCEPTED | 0.26 s | details |
| #24 | ACCEPTED | 0.01 s | details |
| #25 | ACCEPTED | 0.05 s | details |
| #26 | ACCEPTED | 0.15 s | details |
| #27 | ACCEPTED | 0.27 s | details |
Code
#include <bits/stdc++.h>
using namespace std;
long long p = 1000000007;
long long power(long long x, long long n) {
if(n == 0) return (1 % p);
long long xx = power(x, n/2);
xx = (xx * xx) % p;
if(n%2==1) xx = (xx * x) % p;
return xx;
}
struct Vertex {
set<int> adj;
int color;
bool badcolor[6];
};
int main() {
int n, m;
cin >> n >> m;
Vertex E[n];
for (int i = 0; i < m; ++i) {
int u, v;
cin >> u >> v;
E[u - 1].adj.insert(v - 1);
E[v - 1].adj.insert(u - 1);
}
priority_queue<pair<int, int>> heap;
for (int i = 0; i < n; ++i) {
E[i].color = -1;
heap.push({-E[i].adj.size(), i});
for (int j = 0; j < 6; ++j)
E[i].badcolor[j] = false;
}
while (heap.size() > 0) {
int v = heap.top().second;
heap.pop();
if (E[v].color != -1) continue;
for (int i = 0; i < 6; ++i) {
if (!E[v].badcolor[i]) {
E[v].color = i;
for (int u : E[v].adj) {
E[u].badcolor[i] = true;
E[u].adj.erase(v);
heap.push({-E[u].adj.size(), u});
}
break;
}
}
}
for (int i = 0; i < n; ++i) {
cout << E[i].color + 1 << ' ';
}
cout << endl;
return 0;
}
Test details
Test 1
Verdict: ACCEPTED
| input |
|---|
| 5 6 1 2 2 3 3 1 2 4 ... |
| correct output |
|---|
| 2 3 1 2 1 |
| user output |
|---|
| 2 3 1 2 1 |
Test 2
Verdict: ACCEPTED
| input |
|---|
| 100000 199998 1 2 2 3 3 4 4 5 ... |
| correct output |
|---|
| 4 3 2 3 2 3 2 3 2 3 2 3 2 3 2 ... |
| user output |
|---|
| 4 2 1 2 1 2 1 2 1 2 1 2 1 2 1 ... |
Test 3
Verdict: ACCEPTED
| input |
|---|
| 81251 200000 1 2 2 3 3 4 4 5 ... |
| correct output |
|---|
| 3 2 1 4 1 4 1 3 2 4 3 2 1 5 3 ... |
| user output |
|---|
| 4 3 1 2 1 2 1 3 5 3 2 1 4 4 3 ... |
Test 4
Verdict: ACCEPTED
| input |
|---|
| 81251 200000 1 6251 6251 12501 12501 18751 18751 25001 ... |
| correct output |
|---|
| 3 5 3 5 3 5 3 5 3 5 3 5 3 5 3 ... |
| user output |
|---|
| 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 ... |
Test 5
Verdict: ACCEPTED
| input |
|---|
| 2 1 1 2 |
| correct output |
|---|
| 2 1 |
| user output |
|---|
| 2 1 |
Test 6
Verdict: ACCEPTED
| input |
|---|
| 5 7 3 1 3 4 2 4 2 5 ... |
| correct output |
|---|
| 1 3 3 2 1 |
| user output |
|---|
| 1 2 2 3 1 |
Test 7
Verdict: ACCEPTED
| input |
|---|
| 9 10 4 6 5 8 9 6 5 4 ... |
| correct output |
|---|
| 3 2 1 1 3 2 1 1 1 |
| user output |
|---|
| 2 3 1 1 4 2 1 1 1 |
Test 8
Verdict: ACCEPTED
| input |
|---|
| 65 100 34 52 42 65 48 6 62 63 ... |
| correct output |
|---|
| 2 2 3 2 1 1 4 1 5 3 3 4 3 1 1 ... |
| user output |
|---|
| 1 1 1 5 4 2 3 2 4 3 3 2 2 1 2 ... |
Test 9
Verdict: WRONG ANSWER
| input |
|---|
| 661 1000 102 270 29 1 235 291 1 28 ... |
| correct output |
|---|
| 2 1 1 1 2 1 1 2 1 2 2 2 3 2 3 ... |
| user output |
|---|
| 5 4 1 3 2 4 4 2 0 4 2 4 2 2 2 ... |
Test 10
Verdict: WRONG ANSWER
| input |
|---|
| 6658 10000 6255 6351 6240 811 5121 5120 562 563 ... |
| correct output |
|---|
| 3 3 1 1 2 2 1 2 3 1 3 3 2 1 2 ... |
| user output |
|---|
| 5 2 6 3 3 5 4 6 4 4 4 3 5 4 5 ... |
Test 11
Verdict: WRONG ANSWER
| input |
|---|
| 66713 100002 17616 53797 36477 36478 9289 9288 30331 12908 ... |
| correct output |
|---|
| 2 1 1 1 1 1 1 2 1 1 1 1 1 1 1 ... |
| user output |
|---|
| 0 5 5 6 5 0 6 4 6 5 5 4 5 4 4 ... |
Test 12
Verdict: WRONG ANSWER
| input |
|---|
| 133153 199900 84918 102523 65880 121666 112752 112751 119806 92639 ... |
| correct output |
|---|
| 1 3 1 1 1 2 1 2 1 2 1 2 1 2 1 ... |
| user output |
|---|
| 0 1 5 6 0 6 0 2 5 4 6 5 5 5 5 ... |
Test 13
Verdict: WRONG ANSWER
| input |
|---|
| 132902 199904 38449 38448 103004 31700 24769 12112 102436 54041 ... |
| correct output |
|---|
| 1 1 2 1 1 3 1 2 1 1 1 1 1 1 1 ... |
| user output |
|---|
| 5 6 6 6 6 2 0 3 6 6 2 4 5 6 5 ... |
Test 14
Verdict: WRONG ANSWER
| input |
|---|
| 133659 199900 106579 112407 107263 107093 11493 44214 15803 15804 ... |
| correct output |
|---|
| 2 2 1 1 1 2 1 1 1 1 2 1 1 2 3 ... |
| user output |
|---|
| 4 6 6 4 4 3 6 5 6 2 5 6 6 4 4 ... |
Test 15
Verdict: ACCEPTED
| input |
|---|
| 36 85 28 29 8 9 36 30 14 8 ... |
| correct output |
|---|
| 1 3 2 1 3 2 3 2 1 3 2 1 2 1 3 ... |
| user output |
|---|
| 3 2 1 3 2 1 2 1 5 4 1 3 1 5 3 ... |
Test 16
Verdict: ACCEPTED
| input |
|---|
| 40000 119201 16810 16610 34321 34120 38157 37956 24084 23883 ... |
| correct output |
|---|
| 3 2 1 3 2 1 3 2 1 3 2 1 3 2 1 ... |
| user output |
|---|
| 3 1 3 2 1 3 2 1 3 2 1 3 2 1 3 ... |
Test 17
Verdict: ACCEPTED
| input |
|---|
| 80000 199993 29955 9954 47408 27408 51231 51232 37204 37205 ... |
| correct output |
|---|
| 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 ... |
| user output |
|---|
| 2 1 3 2 1 3 2 1 3 2 1 3 2 1 3 ... |
Test 18
Verdict: ACCEPTED
| input |
|---|
| 15 35 3 2 3 4 4 2 5 4 ... |
| correct output |
|---|
| 2 1 3 2 4 5 2 3 4 3 2 4 3 2 1 |
| user output |
|---|
| 1 4 3 2 1 2 1 3 2 1 5 3 2 1 4 |
Test 19
Verdict: ACCEPTED
| input |
|---|
| 143 352 3 2 3 4 4 2 5 4 ... |
| correct output |
|---|
| 1 3 4 1 5 2 1 4 5 1 2 4 3 2 1 ... |
| user output |
|---|
| 2 4 3 2 1 2 1 3 2 1 5 3 2 1 4 ... |
Test 20
Verdict: ACCEPTED
| input |
|---|
| 81256 198855 3 2 3 4 4 2 5 4 ... |
| correct output |
|---|
| 1 3 4 1 5 2 1 4 5 1 2 4 3 2 1 ... |
| user output |
|---|
| 2 4 3 2 1 2 1 3 2 1 5 3 2 1 4 ... |
Test 21
Verdict: ACCEPTED
| input |
|---|
| 15 33 3 2 3 4 4 2 5 4 ... |
| correct output |
|---|
| 1 1 3 2 4 3 2 1 3 5 4 3 2 1 2 |
| user output |
|---|
| 1 5 1 3 4 1 3 1 2 3 5 2 1 4 2 |
Test 22
Verdict: ACCEPTED
| input |
|---|
| 137 326 3 2 3 4 4 2 5 4 ... |
| correct output |
|---|
| 1 1 3 2 4 3 2 1 3 5 4 3 2 1 2 ... |
| user output |
|---|
| 3 2 1 3 4 1 3 1 2 3 5 2 1 4 1 ... |
Test 23
Verdict: ACCEPTED
| input |
|---|
| 82312 198211 3 2 3 4 4 2 5 4 ... |
| correct output |
|---|
| 1 1 3 2 4 3 2 1 3 5 4 3 2 1 2 ... |
| user output |
|---|
| 3 2 1 3 4 1 3 1 2 3 5 2 1 4 1 ... |
Test 24
Verdict: ACCEPTED
| input |
|---|
| 512 1025 2 13 13 3 2 14 14 3 ... |
| correct output |
|---|
| 2 1 2 5 1 3 4 2 1 2 1 4 3 3 3 ... |
| user output |
|---|
| 1 2 6 4 3 2 3 2 5 3 2 4 1 1 1 ... |
Test 25
Verdict: ACCEPTED
| input |
|---|
| 15342 30761 2 13 13 3 2 14 14 3 ... |
| correct output |
|---|
| 1 3 2 5 1 3 4 2 1 2 1 4 1 1 1 ... |
| user output |
|---|
| 3 2 6 4 3 2 3 2 5 3 2 4 1 1 1 ... |
Test 26
Verdict: ACCEPTED
| input |
|---|
| 51148 102547 2 13 13 3 2 14 14 3 ... |
| correct output |
|---|
| 1 3 2 5 1 3 4 2 1 2 1 4 1 1 1 ... |
| user output |
|---|
| 3 2 6 4 3 2 3 2 5 3 2 4 1 1 1 ... |
Test 27
Verdict: ACCEPTED
| input |
|---|
| 99735 199964 2 13 13 3 2 14 14 3 ... |
| correct output |
|---|
| 1 3 2 5 1 3 4 2 1 2 1 4 1 1 1 ... |
| user output |
|---|
| 3 2 6 4 3 2 3 2 5 3 2 4 1 1 1 ... |
