用户输出
1
11
系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#21301 | #1068. 1-08G. JM的最短路径问题 | Wrong Answer | 14 | 13101 ms | 36568 K | C++ 17 / 4.0 K | 自动化82-郭筠陶 | 2020-02-04 17:05:13 |
#include <bits/stdc++.h>
using namespace std;
struct edges {
int id, start, end;
edges() {}
edges(int i, int s, int e) : id(i), start(s), end(e) {}
};
struct edgesCmp {
bool operator()(const edges &a, const edges &b) const { return a.id < b.id; }
};
vector<edges> edgeList(2e5 + 10);
vector<vector<int>> graph(2e5 + 10);
vector<set<edges, edgesCmp>> validGraph(2e5 + 10);
vector<int> depth(2e5 + 10, -1);
vector<bool> visited(2e5 + 10, false);
vector<bool> edgeIsValid(2e5 + 10, false);
vector<bool> usedEdges(2e5 + 10, false);
int n, m, k, cnt = 0;
void bfs();
void dfs(int id, int visitedNum);
int main() {
scanf("%d%d%d", &n, &m, &k);
for (int i = 1; i <= m; ++i) {
int start, end;
scanf("%d%d", &start, &end);
edgeList.at(i) = edges(i, start, end);
graph.at(start).push_back(end);
graph.at(end).push_back(start);
}
bfs();
dfs(1, 0);
}
void bfs() {
queue<int> que;
que.push(1);
depth.at(1) = 0;
while (!que.empty()) {
int curPoint = que.front();
que.pop();
for (int end : graph.at(curPoint)) {
if (depth.at(end) == -1) {
depth.at(end) = depth.at(curPoint) + 1;
que.push(end);
}
}
}
for (int i = 1; i <= m; ++i) {
int start = edgeList.at(i).start, end = edgeList.at(i).end, id = edgeList.at(i).id;
edgeIsValid.at(id) = true;
/*cout << "end" << end << "\tdend\t" << depth[end]
<< "\tstart\t" << start << "\tdstart\t" << depth[start]
<< "\tid\t" << id << endl;*/
if (depth.at(end) == depth.at(start) + 1) {
validGraph.at(end).insert(edges(id, end, start));
edgeList.at(id) = edges(id, start, end);
} else if (depth.at(start) == depth.at(end) + 1) {
validGraph.at(start).insert(edges(id, start, end));
edgeList.at(id) = edges(id, end, start);
} else {
edgeIsValid.at(id) = false;
}
// cout << "depth(1):" << depth.at(1) << endl;
}
int num = 1;
for (int i = 2; i <= n; ++i) {
num *= validGraph.at(i).size();
// cout << i << "\t" << depth.at(i) << "\t" << validGraph.at(i).size() << endl;
if (num > k)
break;
}
k = min(k, num);
cout << k << endl;
}
void dfs(int id, int visitedNum) {
/*cout << "visitedNum:\t" << visitedNum << endl;
for (int i = 1; i <= m; i++)
cout << usedEdges[i] << "\t";
cout << endl;
cout << "cnt" << cnt << "\tk" << k << "\tid" << id << "\tm" << m << endl;*/
if (cnt == k)
return;
if (id == m + 1) {
/*cout << "visitedNum:\t" << visitedNum << endl;
for (int i = 1; i <= m; i++)
cout << usedEdges[i] << "\t";
cout << endl;*/
if (visitedNum == n - 1) {
for (int i = 1; i <= m; i++) {
if (usedEdges[i])
printf("%d", 1);
else
printf("%d", 0);
}
printf("\n");
cnt++;
}
return;
}
int start = edgeList.at(id).start, end = edgeList.at(id).end;
int lastid = (*validGraph.at(end).rbegin()).id;
/*cout << "start\t" << start << "\tend\t" << end << endl;
for(auto it:validGraph.at(end))
cout << it.id << "\t";
cout << endl;
cout << (*validGraph.at(end).end()--).id << endl;
cout << (*validGraph.at(end).rbegin()).id << endl;
cout << "!visited.at(end)\t" << !visited.at(end) << endl;
cout << "edgeIsValid.at(id))" << edgeIsValid.at(id) << endl;
cout << "id!=lastid" << (id != lastid) << endl;*/
if (!visited.at(end) && edgeIsValid.at(id)) {
// cout << "!visited.at(end) && edgeIsValid.at(id)" << endl;
usedEdges.at(id) = true;
visited.at(end) = true;
dfs(id + 1, visitedNum + 1);
usedEdges.at(id) = false;
visited.at(end) = false;
}
if (id != lastid) {
// cout << "id == lastid" << endl;
dfs(id + 1, visitedNum);
}
// id=lastid && id is not valid
}
/*
3 2 1000 1 2 1 3
*/
用户输出
4
110011
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
2
1011
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
1
101001
系统信息
Exited with return code 0
用户输出
2
110011
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
1
100111
系统信息
Exited with return code 0
用户输出
1
001101110
系统信息
Exited with return code 0
6
10111001111001
10111001110101
00111011111001
00111011110101
00111001111011
00111001110111
用户输出
6
00111001110111
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
15 20 100
6 7
15 11
2 15
9 5
9 1
8 2
2 10
2 12
3 11
5 12
14 9
4 11
11 2
13 5
12 7
6
<25 bytes omitted>
用户输出
4
10111100001111110111
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
16 20 100
9 12
7 1
9 6
1 5
5 14
9 11
6 1
3 1
1 16
5 6
11 3
9 5
10 7
13 1
4 3
5 16
9
<22 bytes omitted>
用户输出
4
11010011101111101111
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
16 20 100
8 4
2 16
8 7
6 11
8 9
10 4
1 4
3 9
5 8
3 14
5 6
11 4
10 15
1 16
9 5
13 10
<24 bytes omitted>
用户输出
2
11100111011111010111
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
16 20 100
7 8
6 5
15 1
7 2
2 12
1 7
7 9
13 15
11 14
3 10
8 3
2 14
3 4
1 5
4 15
10 12
<26 bytes omitted>
8
11111111011101101010
11111111011001101011
11111111010111101010
11111111010011101011
111111110
<79 bytes omitted>
用户输出
8
11111111000011111011
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
16 20 100
6 3
15 16
14 2
15 5
6 12
13 16
9 12
16 3
5 11
16 14
10 8
4 3
2 7
8 14
2 3
<28 bytes omitted>
用户输出
4
10011111101110110111
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
16 20 100
4 6
7 15
10 5
8 6
9 11
12 15
14 1
13 7
12 2
4 12
14 16
3 16
9 15
4 5
8 15
<29 bytes omitted>
6
11111011101111011001
11111011101101111001
11111011011111011001
11111011011101111001
111110110
<35 bytes omitted>
用户输出
6
11111011001101111101
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
18 23 100
5 13
10 2
6 3
8 2
1 16
18 10
12 1
2 1
18 2
6 2
4 1
16 7
15 18
17 11
9 17
1
<49 bytes omitted>
4
11111011111101101101100
11111011111101001111100
01111011111101101101110
0111101111110100111111
<3 bytes omitted>
用户输出
4
01111011111101001111110
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
18 23 100
12 14
2 11
1 13
2 7
18 17
16 13
9 13
15 1
9 12
3 4
10 11
18 4
2 18
13 8
5 6
<48 bytes omitted>
4
11111111110111100100110
11111111110111100010110
11111111110011100101110
1111111111001110001111
<3 bytes omitted>
用户输出
4
11111111110011100011110
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
18 23 100
14 1
4 3
2 9
16 10
10 12
10 1
6 15
1 8
3 12
11 14
9 8
15 1
15 9
7 10
1 5
1
<49 bytes omitted>
4
11111111011101111000011
11111111010111111000011
11110111111101111000011
1111011111011111100001
<3 bytes omitted>
用户输出
4
11110111110111111000011
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
18 23 100
5 13
6 7
8 2
13 7
18 12
11 18
9 5
5 4
17 15
11 4
6 13
13 15
18 16
14 15
4 8
<49 bytes omitted>
4
01111110110011011110111
01111110100011111110111
01101110110111011110111
0110111010011111111011
<3 bytes omitted>
用户输出
4
01101110100111111110111
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
18 23 100
4 16
12 17
2 12
16 13
5 8
2 18
5 15
11 5
15 11
13 9
10 4
15 10
13 7
14 15
4
<49 bytes omitted>
4
11001111011011111110011
11001111010111111110011
01011111011011111110011
0101111101011111111001
<3 bytes omitted>
用户输出
4
01011111010111111110011
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
50 70 10000
1 12
43 48
39 50
2 9
3 10
2 26
38 8
38 39
12 17
6 19
31 21
17 23
39 25
25
<381 bytes omitted>
1536
1111111110111011111111111001001111011101001111110101101001101100001011
1111111110111011111111
<110498 bytes omitted>
用户输出
1536
1010111010110111101101100000101111011101011110111111111101101111001111
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
11 18 55555
1 2
1 3
2 4
2 5
3 4
3 5
4 6
4 7
5 6
5 7
6 8
6 9
7 8
7 9
8 10
8 11
9 10
<7 bytes omitted>
256
111100110011001100
111100110011001001
111100110011000110
111100110011000011
111100110010011
<5025 bytes omitted>
用户输出
256
110011001100110011
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
17 30 33333
1 2
1 3
2 4
2 5
3 4
3 5
4 6
4 7
5 6
5 7
6 8
6 9
7 8
7 9
8 10
8 11
9 10
<91 bytes omitted>
16384
111100110011001100110011001100
111100110011001100110011001001
11110011001100110011001100011
<524195 bytes omitted>
用户输出
16384
110011001100110011001100110011
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
21 38 26315
1 2
1 3
2 4
2 5
3 4
3 5
4 6
4 7
5 6
5 7
6 8
6 9
7 8
7 9
8 10
8 11
9 10
<147 bytes omitted>
26315
11110011001100110011001100110011001100
11110011001100110011001100110011001001
1111001100110
<1052507 bytes omitted>
用户输出
26315
11001100110011001100110011001100110011
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
60 100 10000
15 8
38 1
9 52
43 48
41 14
36 24
40 50
17 32
56 6
57 19
1 58
35 38
45 13
2 40
60 9
39 2
<484 bytes omitted>
10000
111111111011110111111000000010011111110111100101110010000101010001110010001111010101110110001
<1019907 bytes omitted>
用户输出
10000
1100000000100001101101001010100000101111110001011001011100111101111101111111111101111101101010111101
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
70 100 10000
27 61
60 24
14 59
1 15
51 66
29 14
43 35
50 37
69 45
39 22
53 62
26 48
59 15
49 26
15 5
<487 bytes omitted>
10000
111110111111111111110111111000011111000011010011011111101011100111110101011000101011111101011
<1019907 bytes omitted>
用户输出
10000
1101000011110111111111011110010100110001010110100110010011111101111101111111110110111111010110111111
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
10000 20000 50
6058 5831
7627 4199
110 625
8448 3408
6892 8141
7330 3565
9357 7
9873 342
8897 7158
5
<195532 bytes omitted>
50
111011001011000000010111110111111010111011111110101110111111110100111111001111111110001111101001
<1000004 bytes omitted>
用户输出
50
10000 20000 50
1033 1905
3460 6300
2951 4230
9132 4742
2214 3056
8918 4400
8082 773
7830 2062
9982 9
<195515 bytes omitted>
50
111111111111110111101101111111010110011111111110111111010011111010111111101001111111101110110111
<1000004 bytes omitted>
用户输出
50
10000 20000 50
6847 3482
817 3510
5123 1951
5304 7208
3742 1032
5717 2194
4923 7301
6246 811
8238 38
<195437 bytes omitted>
50
110111111110111101111000111111110011011111100001111101101111101110101011111101110010101001111011
<1000004 bytes omitted>
用户输出
50
100000 200000 5
5288 66997
269 62477
5814 98286
13854 35535
69987 11113
25615 15393
58259 97349
2249
<2355583 bytes omitted>
5
1011111101011110111101111111101110110011011111011111101111111111110110101111111100100111111100111
<999913 bytes omitted>
用户输出
5
100000 200000 5
45437 10342
44133 50047
89844 57436
35625 95126
99613 23809
28134 81440
459 22867
31
<2355778 bytes omitted>
5
1111011010011111111110001011110111000111111111101101001001111111011111111101100111111111111111011
<999913 bytes omitted>
用户输出
5
100000 200000 5
72662 259
91387 89352
43750 9698
58271 64237
72021 59557
4552 19824
56421 91539
1248
<2355530 bytes omitted>
5
1111011011111011011111111111111110111110100010111010110111110111100101111101111100110110111010110
<999913 bytes omitted>
用户输出
5
1000 200000 5
755 942
475 775
602 689
640 210
706 141
566 687
760 797
228 183
814 428
980 405
923 23
<1557473 bytes omitted>
5
1000110101100110000010011100010001100100111010011111000010101011011101001001101010000011001010000
<999913 bytes omitted>
用户输出
5
1000 200000 5
134 693
836 367
482 570
668 929
930 558
617 679
141 462
822 707
576 763
512 498
502 12
<1557154 bytes omitted>
5
1010100000000000111000100001111100110100001100011011011111100001000011000101000011000001110110101
<999913 bytes omitted>
用户输出
5
1000 20000 50
946 410
682 771
489 583
728 539
536 656
994 907
555 1
266 127
394 559
122 934
973 453
<155563 bytes omitted>
50
111011111110000101101101110010111000100110011000000001010010101101010000010001110101100000100101
<1000004 bytes omitted>
用户输出
50
1000 20000 50
770 555
656 713
734 858
763 559
23 372
742 652
944 40
201 412
822 755
683 914
598 664
<155673 bytes omitted>
50
010001000010000001001000100100010001010101000000110010101110000100000000000001011100000000011000
<1000004 bytes omitted>
用户输出
50
101 910 1098
86 88
32 38
83 88
69 67
26 75
37 58
31 32
27 41
23 42
11 76
17 95
9 81
83 55
90 99
81 1
<5254 bytes omitted>
1098
0100100110000000001101000000100001010010001000001001101001001010000000000000001001000001000000
<1001282 bytes omitted>
用户输出
1098
26 105 9523
7 22
26 6
13 20
18 12
6 1
25 3
14 18
15 19
7 12
5 10
16 22
18 13
1 25
20 19
16 2
2 10
2
<467 bytes omitted>
2304
1100110010001000001011101001000000100010000000001000000001110001000000000110100000100000000100
<246434 bytes omitted>
用户输出
2304
000010001000100000000110100000000010100001000001101000001110000100000000011000100010000000010001100001100
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
26 105 9523
1 11
24 8
25 12
16 19
16 13
16 8
24 15
20 23
18 2
12 22
12 23
17 10
16 9
17 19
7 13
13 9
<478 bytes omitted>
9523
1110100100000000110100100101000011100000000000010000110010100000000010010001001000100001000000
<1018867 bytes omitted>
用户输出
9523
100000000000000000000000000001000100000001010001100001000110000000001001000100101110011001000001100100011
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
41 78 12820
26 25
38 2
36 27
4 36
24 40
25 5
19 14
4 22
27 37
13 20
18 6
21 10
19 34
26 17
31 27
36
<346 bytes omitted>
12820
011111110110110011001011011111101100011110010010100000001000010100101010001110
0111111101101
<1025507 bytes omitted>
用户输出
12820
001110010000100001011000101000000101111110111010000001111011110110111111001101
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
102 198 5050
83 79
73 35
39 30
31 79
26 38
101 36
38 29
47 54
52 1
41 49
73 88
46 88
63 46
1 33
42 7
<1085 bytes omitted>
5050
1011111011001101100101001111101101111010001110101101110110110111111010001111010111001101101001
<1009906 bytes omitted>
用户输出
5050
000011001000110110010100101101010101101000111000110111000000000100111100011101001110000100001110010000001111101100100011010
<76 bytes omitted>
1019 1972 500
261 496
405 855
946 491
28 814
78 334
938 1004
517 150
65 250
114 721
588 714
877 754
<15367 bytes omitted>
500
11011010001011111100001111100111111010101111101111111011111110111001110101001101101111011111010
<986905 bytes omitted>
用户输出
500
10172 18765 49
8675 8281
56 7711
7304 3714
1625 1207
6893 9729
8527 6536
859 4207
7510 2968
4617 878
<184128 bytes omitted>
49
111110101010111101100110111111011111111111110001111111111111001111101111000100110111111111100110
<919487 bytes omitted>
用户输出
49
20254 39998 21
16666 17950
9556 19055
8811 7496
5477 7841
6433 11698
14778 15913
4220 17854
17530 53
<436023 bytes omitted>
21
111001101110110111110111011111101111111111111111111110111101111111100111011001110101101110111101
<839904 bytes omitted>
用户输出
21
46318 78521 10
7727 21263
42519 44968
41236 4161
28790 22964
37871 27235
11725 32384
28473 41375
131
<904691 bytes omitted>
10
111111110110011011011010111110111011111111111111101101110111111111111110111111111110101111111111
<785134 bytes omitted>
用户输出
10
200000 200000 5
114079 181756
79232 71046
70285 17203
34351 199109
83828 190462
74596 111695
147119
<2577827 bytes omitted>
2
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
<399907 bytes omitted>
用户输出
2
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
<199875 bytes omitted>
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
99998 100000 10
96653 56927
81423 55810
59451 63093
44056 93429
45626 97641
57608 46703
19114 20322
<1177845 bytes omitted>
2
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
<199907 bytes omitted>
用户输出
2
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
<99875 bytes omitted>
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
180000 180001 5
120960 85527
158406 61941
178311 158686
50693 145763
63784 46782
145852 173482
20815
<2298114 bytes omitted>
2
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
<359909 bytes omitted>
用户输出
2
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
<179876 bytes omitted>
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0