CSES - NOI 2019 - Results
Submission details
Task:Graph Ordering
Sender:Marcus Alexander Karmi September
Submission time:2019-03-06 12:13:19 +0200
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
#40
#50
Test results
testverdicttimegroup
#1ACCEPTED0.17 s1, 4, 5details
#20.18 s1, 5details
#3ACCEPTED0.10 s1, 5details
#4ACCEPTED0.11 s1, 5details
#5ACCEPTED0.13 s1, 5details
#60.02 s2, 3, 5details
#7ACCEPTED0.01 s2, 3, 5details
#80.03 s2, 3, 4, 5details
#90.01 s2, 3, 4, 5details
#100.02 s2, 3, 4, 5details
#110.02 s2, 3, 5details
#120.01 s2, 3, 5details
#130.02 s2, 3, 4, 5details
#140.02 s2, 3, 4, 5details
#150.02 s2, 3, 4, 5details
#160.02 s2, 3, 4, 5details
#170.02 s2, 3, 4, 5details
#180.03 s2, 3, 4, 5details
#190.02 s3, 4, 5details
#200.02 s3, 4, 5details
#210.02 s3, 4, 5details
#220.02 s3, 4, 5details
#230.03 s3, 5details
#240.02 s3, 5details
#25ACCEPTED0.03 s3, 5details
#26ACCEPTED0.01 s3, 5details
#270.02 s3, 5details
#280.25 s5details
#290.25 s5details
#300.26 s4, 5details
#310.23 s4, 5details
#320.25 s4, 5details
#330.25 s4, 5details
#34ACCEPTED0.21 s5details
#35ACCEPTED0.19 s5details
#36ACCEPTED0.20 s5details
#37ACCEPTED0.02 s1, 2, 3, 4, 5details
#380.01 s2, 3, 5details
#390.02 s2, 3, 5details
#400.02 s2, 3, 5details
#41ACCEPTED0.02 s1, 2, 3, 5details
#420.02 s2, 3, 5details
#430.02 s3, 4, 5details
#440.03 s3, 4, 5details
#450.03 s2, 3, 4, 5details
#460.02 s2, 3, 4, 5details
#470.02 s2, 3, 5details
#480.02 s3, 4, 5details
#490.03 s4, 5details

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:87:9: warning: ignoring return value of 'int system(const char*)', declared with attribute warn_unused_result [-Wunused-result]
   system("pause");
   ~~~~~~^~~~~~~~~
input/code.cpp:103:9: warning: ignoring return value of 'int system(const char*)', declared with attribute warn_unused_result [-Wunused-result]
   system("pause");
   ~~~~~~^~~~~~~~~
input/code.cpp:107:8: warning: ignoring return value of 'int system(const char*)', declared with attribute warn_unused_result [-Wunused-result]
  system("pause");
  ~~~~~~^~~~~~~~~

Code

#define _CRT_SECURE_NO_DEPRECATE
#include <algorithm>
#include <numeric>
#include <iterator>
#include <string>
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <map>
#include <queue>
using namespace std;
typedef long long		ll;
typedef pair<int, int>	ii;
typedef vector<ii>		vii;
typedef vector<int>		vi;
#define INF 1000000000
#define REP(i, a, b) for (int i = int(a); i < int(b); ++i)

vi ans;

void visit(int p, const vector<vi> & nabo, vector<vector<bool> > & nabo_valid,
	vector<char> & mark) {

	if (mark[p] == 'P')
		return;

	mark[p] = 'T';
	REP(i, 0, nabo[p].size()) {
		//naboen
		int q = nabo[p][i];

		//denne veien settes som ugyldig
		if (mark[q] == 'T')
			nabo_valid[p][i] = false;
		else
			visit(q, nabo, nabo_valid, mark);
	}
	mark[p] = 'P';
	ans.push_back(p);
}


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	//nodes and edges
	int n, m;
	cin >> n >> m;

	//naboliste
	vector<vi> nabo(n + 1);
	//gyldig å gå denne veien?
	vector<vector<bool> > nabo_valid(n + 1);


	REP(i, 0, m) {
		int p, q;
		cin >> p >> q;
		//anta går begge veier
		nabo[p].push_back(q);
		nabo_valid[p].push_back(true);

		nabo[q].push_back(p);
		nabo_valid[q].push_back(true);
	}

	//antall kandidater for source
	int n_cand = 0;
	vi cand;
	REP(i, 1, n + 1) {
		if (nabo[i].size() == 1) {
			n_cand++;
			cand.push_back(i);
		}
	}

	if (n_cand == 0) {
		cand.push_back(1);
		cand.push_back(n);
	}

	//umulig
	if (n_cand > 2) {
		cout << "IMPOSSIBLE" << endl;
		system("pause");
		return 0;
	}

	cand = { 1 };

	REP(i, 0, cand.size()) {
		ans = {};
		vector<vector<bool> > nabo_valid_temp = nabo_valid;
		vector<char> mark(n + 1, 'N');

		visit(cand[i], nabo, nabo_valid_temp, mark);

		for (int z : ans)
			cout << z << " ";
		cout << endl;
		system("pause");
		return 0;
	}

	system("pause");
	return 0;
}

Test details

Test 1

Group: 1, 4, 5

Verdict: ACCEPTED

input
100000 99999
8326 74462
11810 58064
21677 73087
62986 25005
...

correct output
1 44159 25721 84659 90058 9960...

user output
100000 55408 4224 23528 55621 ...

Error:
sh: 1: pause: not found

Test 2

Group: 1, 5

Verdict:

input
100000 99999
28990 31200
86271 56882
61089 18658
52422 57504
...

correct output
68068 86325 91398 75677 51068 ...

user output
75520 37121 89333 44052 51784 ...

Error:
sh: 1: pause: not found

Test 3

Group: 1, 5

Verdict: ACCEPTED

input
100000 99999
29378 80094
12282 29378
96138 29378
61870 29378
...

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Error:
sh: 1: pause: not found

Test 4

Group: 1, 5

Verdict: ACCEPTED

input
100000 99999
97935 71091
9181 31715
73649 47675
45394 25464
...

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Error:
sh: 1: pause: not found

Test 5

Group: 1, 5

Verdict: ACCEPTED

input
100000 99999
2897 55594
11759 89041
56061 8717
69672 73046
...

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Error:
sh: 1: pause: not found

Test 6

Group: 2, 3, 5

Verdict:

input
100 200
55 10
33 57
68 39
29 27
...

correct output
IMPOSSIBLE

user output
33 80 4 6 2 35 100 5 14 93 21 ...

Error:
sh: 1: pause: not found

Test 7

Group: 2, 3, 5

Verdict: ACCEPTED

input
100 175
71 86
100 88
83 92
25 73
...

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Error:
sh: 1: pause: not found

Test 8

Group: 2, 3, 4, 5

Verdict:

input
100 200
26 58
49 25
66 20
20 85
...

correct output
1 2 86 60 34 92 23 4 44 89 76 ...

user output
37 22 50 91 75 44 89 14 94 7 3...

Error:
sh: 1: pause: not found

Test 9

Group: 2, 3, 4, 5

Verdict:

input
100 195
19 28
63 48
1 57
1 20
...

correct output
12 97 18 74 36 10 78 50 61 95 ...

user output
71 32 24 54 39 96 100 90 5 61 ...

Error:
sh: 1: pause: not found

Test 10

Group: 2, 3, 4, 5

Verdict:

input
100 193
48 66
15 67
32 14
36 78
...

correct output
1 56 13 32 14 49 75 93 18 6 54...

user output
19 21 74 5 4 54 23 58 39 42 40...

Error:
sh: 1: pause: not found

Test 11

Group: 2, 3, 5

Verdict:

input
100 195
47 68
57 61
45 17
80 61
...

correct output
57 20 83 41 25 33 60 91 59 7 7...

user output
60 88 37 100 56 18 45 70 99 94...

Error:
sh: 1: pause: not found

Test 12

Group: 2, 3, 5

Verdict:

input
100 185
43 78
76 99
78 39
83 61
...

correct output
78 43 32 88 26 28 64 81 7 72 2...

user output
93 82 4 63 73 89 9 44 19 36 57...

Error:
sh: 1: pause: not found

Test 13

Group: 2, 3, 4, 5

Verdict:

input
99 132
96 16
18 89
98 50
66 26
...

correct output
1 12 45 71 97 22 35 9 60 27 20...

user output
48 28 95 39 33 15 86 80 5 54 4...

Error:
sh: 1: pause: not found

Test 14

Group: 2, 3, 4, 5

Verdict:

input
98 144
25 6
30 34
58 25
31 41
...

correct output
32 7 92 1 63 86 87 14 90 17 81...

user output
92 7 32 57 42 16 66 53 50 65 9...

Error:
sh: 1: pause: not found

Test 15

Group: 2, 3, 4, 5

Verdict:

input
96 145
19 70
72 92
27 72
17 85
...

correct output
1 50 30 4 10 48 42 5 70 19 29 ...

user output
30 70 93 87 54 92 22 39 13 51 ...

Error:
sh: 1: pause: not found

Test 16

Group: 2, 3, 4, 5

Verdict:

input
96 158
79 74
41 70
8 5
73 90
...

correct output
7 59 44 27 1 30 49 28 80 52 15...

user output
52 36 95 14 83 46 38 72 21 55 ...

Error:
sh: 1: pause: not found

Test 17

Group: 2, 3, 4, 5

Verdict:

input
96 142
95 35
67 89
91 70
48 21
...

correct output
13 20 81 33 1 51 19 69 16 85 6...

user output
20 81 33 13 85 16 89 50 67 5 2...

Error:
sh: 1: pause: not found

Test 18

Group: 2, 3, 4, 5

Verdict:

input
72 111
70 17
25 3
58 24
52 9
...

correct output
21 59 48 8 1 2 31 10 11 41 4 5...

user output
8 48 59 21 4 51 47 49 24 37 20...

Error:
sh: 1: pause: not found

Test 19

Group: 3, 4, 5

Verdict:

input
988 1563
402 701
830 801
50 578
8 144
...

correct output
1 136 368 683 447 304 131 53 8...

user output
22 872 987 189 349 700 626 34 ...

Error:
sh: 1: pause: not found

Test 20

Group: 3, 4, 5

Verdict:

input
994 1555
171 541
66 915
330 350
494 251
...

correct output
1 164 205 151 951 797 4 654 14...

user output
164 205 151 855 276 171 605 54...

Error:
sh: 1: pause: not found

Test 21

Group: 3, 4, 5

Verdict:

input
1000 2000
711 947
775 441
691 471
844 28
...

correct output
1 676 731 662 248 31 165 558 8...

user output
358 899 300 458 41 581 896 234...

Error:
sh: 1: pause: not found

Test 22

Group: 3, 4, 5

Verdict:

input
1000 2000
811 889
873 984
83 52
144 511
...

correct output
60 909 522 568 40 77 181 441 8...

user output
44 522 21 474 199 115 995 558 ...

Error:
sh: 1: pause: not found

Test 23

Group: 3, 5

Verdict:

input
1000 1869
625 715
448 714
110 927
432 1000
...

correct output
224 326 221 30 76 475 666 694 ...

user output
437 656 143 375 845 422 740 65...

Error:
sh: 1: pause: not found

Test 24

Group: 3, 5

Verdict:

input
1000 1783
709 1
182 768
355 40
786 260
...

correct output
230 6 135 678 346 19 470 960 3...

user output
731 174 320 416 485 179 384 28...

Error:
sh: 1: pause: not found

Test 25

Group: 3, 5

Verdict: ACCEPTED

input
1000 2000
92 876
273 598
287 535
526 972
...

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Error:
sh: 1: pause: not found

Test 26

Group: 3, 5

Verdict: ACCEPTED

input
1000 1910
789 821
553 740
889 527
488 730
...

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Error:
sh: 1: pause: not found

Test 27

Group: 3, 5

Verdict:

input
1000 1608
910 416
503 898
928 14
412 903
...

correct output
140 404 739 563 63 794 623 948...

user output
580 781 87 134 706 126 27 731 ...

Error:
sh: 1: pause: not found

Test 28

Group: 5

Verdict:

input
100000 198666
5659 89691
91040 53375
96642 56177
28768 57001
...

correct output
45598 74078 1039 83702 16344 8...

user output
70426 73854 45701 96736 63427 ...

Error:
sh: 1: pause: not found

Test 29

Group: 5

Verdict:

input
100000 197194
41636 91770
63018 23827
39207 93713
67765 47715
...

correct output
79054 61855 53279 55546 60860 ...

user output
99277 17639 55460 681 40831 27...

Error:
sh: 1: pause: not found

Test 30

Group: 4, 5

Verdict:

input
100000 199985
13674 42886
51349 6858
78502 18751
13628 65936
...

correct output
17857 81664 4369 61462 79754 8...

user output
71347 73257 62992 15607 20359 ...

Error:
sh: 1: pause: not found

Test 31

Group: 4, 5

Verdict:

input
100000 200000
27666 33166
7161 81452
73134 30281
5106 29308
...

correct output
76869 5635 23236 12666 61633 8...

user output
23867 54434 38886 68226 88418 ...

Error:
sh: 1: pause: not found

Test 32

Group: 4, 5

Verdict:

input
100000 200000
62814 54729
98407 26888
91808 70132
58916 49730
...

correct output
19788 11202 3496 24237 68564 5...

user output
18613 98361 82334 93407 9876 7...

Error:
sh: 1: pause: not found

Test 33

Group: 4, 5

Verdict:

input
100000 200000
2299 91653
21125 75544
54029 94067
86513 45051
...

correct output
1 20339 9304 40427 67694 95656...

user output
17801 53627 55081 73104 41086 ...

Error:
sh: 1: pause: not found

Test 34

Group: 5

Verdict: ACCEPTED

input
100000 200000
34688 93668
78127 18902
55150 33116
273 88797
...

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Error:
sh: 1: pause: not found

Test 35

Group: 5

Verdict: ACCEPTED

input
100000 200000
21026 14630
5605 59639
25604 78683
55713 70513
...

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Error:
sh: 1: pause: not found

Test 36

Group: 5

Verdict: ACCEPTED

input
100000 200000
63190 73606
52072 54105
22092 31495
9189 37924
...

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Error:
sh: 1: pause: not found

Test 37

Group: 1, 2, 3, 4, 5

Verdict: ACCEPTED

input
2 1
2 1

correct output
1 2

user output
2 1 

Error:
sh: 1: pause: not found

Test 38

Group: 2, 3, 5

Verdict:

input
7 9
1 2
1 3
2 3
1 4
...

correct output
IMPOSSIBLE

user output
3 2 5 4 7 6 1 

Error:
sh: 1: pause: not found

Test 39

Group: 2, 3, 5

Verdict:

input
9 12
1 2
2 3
3 1
4 5
...

correct output
IMPOSSIBLE

user output
3 2 6 5 9 8 7 4 1 

Error:
sh: 1: pause: not found

Test 40

Group: 2, 3, 5

Verdict:

input
5 5
4 2
4 3
2 1
3 1
...

correct output
4 2 3 1 5

user output
3 4 2 5 1 

Error:
sh: 1: pause: not found

Test 41

Group: 1, 2, 3, 5

Verdict: ACCEPTED

input
4 3
1 2
3 2
4 2

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Error:
sh: 1: pause: not found

Test 42

Group: 2, 3, 5

Verdict:

input
17 30
4 1
3 14
6 16
13 6
...

correct output
7 8 11 15 1 2 9 3 14 13 5 10 1...

user output
14 13 3 9 2 5 10 17 12 16 6 4 ...

Error:
sh: 1: pause: not found

Test 43

Group: 3, 4, 5

Verdict:

input
992 1712
377 709
847 640
261 902
761 693
...

correct output
870 1 925 928 950 257 766 520 ...

user output
148 29 939 345 914 862 274 950...

Error:
sh: 1: pause: not found

Test 44

Group: 3, 4, 5

Verdict:

input
990 1672
305 445
800 155
365 779
824 247
...

correct output
108 461 160 696 895 655 376 21...

user output
461 160 326 88 376 213 655 895...

Error:
sh: 1: pause: not found

Test 45

Group: 2, 3, 4, 5

Verdict:

input
99 169
35 32
97 43
22 62
33 7
...

correct output
19 70 62 22 54 78 25 14 3 81 1...

user output
70 62 14 25 78 54 17 81 3 22 5...

Error:
sh: 1: pause: not found

Test 46

Group: 2, 3, 4, 5

Verdict:

input
99 164
62 73
19 35
55 92
79 91
...

correct output
21 25 64 90 17 15 89 95 70 33 ...

user output
25 21 26 61 2 59 87 92 4 55 32...

Error:
sh: 1: pause: not found

Test 47

Group: 2, 3, 5

Verdict:

input
53 68
7 46
51 14
3 18
8 40
...

correct output
32 30 38 33 27 12 8 20 2 34 45...

user output
34 2 20 45 48 41 39 3 18 29 26...

Error:
sh: 1: pause: not found

Test 48

Group: 3, 4, 5

Verdict:

input
996 1902
661 201
19 613
895 438
180 32
...

correct output
220 795 198 239 40 164 773 834...

user output
873 198 795 239 40 533 232 56 ...

Error:
sh: 1: pause: not found

Test 49

Group: 4, 5

Verdict:

input
6110 11528
3366 4718
3226 2188
5022 1186
3205 5349
...

correct output
1 2527 2211 554 4201 4522 1494...

user output
1600 1850 2436 3734 2390 4456 ...

Error:
sh: 1: pause: not found