Submission details
Task:Coloring
Sender:Aalto CS-A1140 Team 2
Submission time:2025-11-08 16:06:59 +0200
Language:C++ (C++17)
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.01 sdetails
#2ACCEPTED0.08 sdetails
#3ACCEPTED0.07 sdetails
#4ACCEPTED0.07 sdetails
#5ACCEPTED0.01 sdetails
#6ACCEPTED0.01 sdetails
#7ACCEPTED0.01 sdetails
#8ACCEPTED0.01 sdetails
#9ACCEPTED0.01 sdetails
#10ACCEPTED0.01 sdetails
#11ACCEPTED0.06 sdetails
#12ACCEPTED0.13 sdetails
#13ACCEPTED0.13 sdetails
#14ACCEPTED0.13 sdetails
#15ACCEPTED0.01 sdetails
#160.05 sdetails
#17ACCEPTED0.10 sdetails
#18ACCEPTED0.01 sdetails
#19ACCEPTED0.01 sdetails
#20ACCEPTED0.07 sdetails
#21ACCEPTED0.01 sdetails
#22ACCEPTED0.01 sdetails
#23ACCEPTED0.07 sdetails
#24ACCEPTED0.01 sdetails
#25ACCEPTED0.02 sdetails
#26ACCEPTED0.04 sdetails
#27ACCEPTED0.07 sdetails

Compiler report

input/code.cpp: In function 'void dfs(int)':
input/code.cpp:12:25: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   12 |         if (g[s].size() < lim) return;
      |             ~~~~~~~~~~~~^~~~~

Code

#include <bits/stdc++.h>
using namespace std;

const int N = 2e5 + 1;
vector<int> g[N];
int col[N];

int lim = 0;

void dfs(int s) {
	if (col[s]) return;
	if (g[s].size() < lim) return;
	int seen[7] {};
	for (int u : g[s]) {
		seen[col[u]]++;
	}
	col[s] = 1;
	while (col[s] <= 6 && seen[col[s]]) col[s]++;
	if (col[s] > 6) assert(false);
	for (int u : g[s]) {
		dfs(u);
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int n, m;
	cin >> n >> m;

	for (int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	lim = 6;
	for (int i = 0; i < n; ++i) {
		dfs(i);
	}
	lim = 0;
	for (int i = 0; i < n; ++i) {
		dfs(i);
	}

	for (int i = 0; i < n; ++i) {
		cout << col[i] << " ";
	}
	cout << endl;
}

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
1 2 3 1 3 

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
2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 ...

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
3 4 2 1 2 1 2 3 4 1 3 4 2 2 1 ...

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
3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ...

Test 5

Verdict: ACCEPTED

input
2 1
1 2

correct output
2 1

user output
1 2 

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 1 3 

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
1 2 2 2 1 3 2 2 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 3 1 2 2 3 2 2 1 3 1 1 1 1 ...

Test 9

Verdict: ACCEPTED

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
1 1 1 2 2 1 2 2 1 2 2 1 3 2 1 ...

Test 10

Verdict: ACCEPTED

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
1 2 1 2 1 1 1 1 1 1 2 2 3 2 1 ...

Test 11

Verdict: ACCEPTED

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
1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 ...

Test 12

Verdict: ACCEPTED

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
1 1 1 1 1 2 1 2 1 2 1 2 1 1 1 ...

Test 13

Verdict: ACCEPTED

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
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

Test 14

Verdict: ACCEPTED

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
1 1 2 1 1 2 2 2 1 1 1 1 1 1 2 ...

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
2 3 1 2 3 1 4 1 2 3 1 2 1 3 4 ...

Test 16

Verdict:

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
(empty)

Error:
code: input/code.cpp:19: void dfs(int): Assertion `false' failed.

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 3 1 2 4 2 3 1 2 3 1 2 1 3 2 ...

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
2 1 3 4 2 4 2 3 2 3 4 2 3 4 1 

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
1 2 3 4 1 4 1 3 1 3 4 1 3 4 2 ...

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
1 2 3 4 1 4 1 3 1 3 4 1 3 4 2 ...

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 1 2 4 3 4 2 3 1 2 3 1 3 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
1 1 2 4 3 4 2 3 1 2 3 1 3 4 2 ...

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
1 1 2 4 3 4 2 3 1 2 3 1 3 4 2 ...

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
2 1 2 3 1 4 1 2 3 1 3 5 3 3 3 ...

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
1 2 1 3 2 4 2 1 3 1 2 5 3 3 3 ...

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
1 2 1 3 2 4 2 1 3 1 2 5 3 3 3 ...

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
1 2 1 3 2 4 2 1 3 1 2 5 3 3 3 ...