Compare commits
2 Commits
e32b5e9ec0
...
670b2a624d
Author | SHA1 | Date | |
---|---|---|---|
670b2a624d | |||
61ee77b35f |
@ -20,6 +20,7 @@ int main()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int t=b[1],w=l[1];
|
int t=b[1],w=l[1];
|
||||||
if(t>w){
|
if(t>w){
|
||||||
int e=t;
|
int e=t;
|
||||||
@ -31,6 +32,7 @@ int main()
|
|||||||
ans+=2;
|
ans+=2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
t=b[0],w=l[0];
|
t=b[0],w=l[0];
|
||||||
if(t>w){
|
if(t>w){
|
||||||
int e=t;
|
int e=t;
|
||||||
@ -42,6 +44,7 @@ int main()
|
|||||||
ans+=2;
|
ans+=2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int ax=b[0]-l[0];
|
int ax=b[0]-l[0];
|
||||||
int bx=b[1]-l[1];
|
int bx=b[1]-l[1];
|
||||||
if(ax<0) ax*=-1;
|
if(ax<0) ax*=-1;
|
||||||
|
3
4077_net/Readme.md
Normal file
3
4077_net/Readme.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# 标题
|
||||||
|
|
||||||
|
* 内容
|
3
4077_net/doc/Readme.md
Normal file
3
4077_net/doc/Readme.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# 标题
|
||||||
|
|
||||||
|
* 内容
|
BIN
4077_net/doc/社区网络.pdf
Normal file
BIN
4077_net/doc/社区网络.pdf
Normal file
Binary file not shown.
6
4077_net/main.cpp
Normal file
6
4077_net/main.cpp
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
std::cout << "Hello Easy C++ project!" << std::endl;
|
||||||
|
}
|
BIN
4077_net/main.exe
Normal file
BIN
4077_net/main.exe
Normal file
Binary file not shown.
84
4077_net/net.cpp
Normal file
84
4077_net/net.cpp
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
#include <iostream>
|
||||||
|
using namespace std;
|
||||||
|
int n, now = 0, m, e[100001][2] = { 0 }, g[100001] = { 0 }, p[100001][4] = { 0 };
|
||||||
|
int mins(int a, int b)
|
||||||
|
{
|
||||||
|
return a < b ? a : b;
|
||||||
|
}
|
||||||
|
int maxs(int a, int b)
|
||||||
|
{
|
||||||
|
return a > b ? a : b;
|
||||||
|
}
|
||||||
|
void party(int a, int b)
|
||||||
|
{
|
||||||
|
// cout << a << " " << b << ":";
|
||||||
|
if (g[a] == 0 && g[b] == 0) {
|
||||||
|
g[a] = ++now;
|
||||||
|
g[b] = now;
|
||||||
|
int a0 = e[a][0], b0 = e[b][0], a1 = e[a][1], b1 = e[b][1];
|
||||||
|
p[now][0] = mins(a0, b0);
|
||||||
|
p[now][1] = mins(a1, b1);
|
||||||
|
p[now][2] = maxs(a0, b0);
|
||||||
|
p[now][3] = maxs(a1, b1);
|
||||||
|
} else {
|
||||||
|
while (p[g[a]][0] == -1) {
|
||||||
|
a = p[g[a]][3];
|
||||||
|
}
|
||||||
|
while (p[g[b]][0] == -1) {
|
||||||
|
b = p[g[b]][3];
|
||||||
|
}
|
||||||
|
if (g[a] > g[b]) {
|
||||||
|
int o = a;
|
||||||
|
a = b;
|
||||||
|
b = o;
|
||||||
|
}
|
||||||
|
/*cout << g[a] << "?";
|
||||||
|
cout << g[b] << "?" << endl;*/
|
||||||
|
if (g[a] == 0) {
|
||||||
|
g[a] = g[b];
|
||||||
|
int a0 = e[a][0], a1 = e[a][1];
|
||||||
|
p[g[b]][0] = mins(a0, p[g[b]][0]);
|
||||||
|
p[g[b]][1] = mins(a1, p[g[b]][1]);
|
||||||
|
p[g[b]][2] = maxs(a0, p[g[b]][2]);
|
||||||
|
p[g[b]][3] = maxs(a1, p[g[b]][3]);
|
||||||
|
} else {
|
||||||
|
if (g[a] != g[b]) {
|
||||||
|
p[g[b]][0] = mins(p[g[a]][0], p[g[b]][0]);
|
||||||
|
p[g[b]][1] = mins(p[g[a]][1], p[g[b]][1]);
|
||||||
|
p[g[b]][2] = maxs(p[g[a]][2], p[g[b]][2]);
|
||||||
|
p[g[b]][3] = maxs(p[g[a]][3], p[g[b]][3]);
|
||||||
|
p[g[a]][0] = -1, p[g[a]][3] = b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}/*
|
||||||
|
for (int i = 0; i <= 3; i++) {
|
||||||
|
cout << p[g[a]][i] << " ";
|
||||||
|
}
|
||||||
|
cout << endl;
|
||||||
|
for (int i = 0; i <= 3; i++) {
|
||||||
|
cout << p[g[b]][i] << " ";
|
||||||
|
}
|
||||||
|
cout << endl;*/
|
||||||
|
}
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
cin >> n >> m;
|
||||||
|
for (int i = 1; i <= n; i++) {
|
||||||
|
cin >> e[i][0] >> e[i][1];
|
||||||
|
}
|
||||||
|
for (int i = 1; i <= m; i++) {
|
||||||
|
int yi, er;
|
||||||
|
cin >> yi >> er;
|
||||||
|
//cout << i << "||";
|
||||||
|
party(yi, er);
|
||||||
|
}
|
||||||
|
int ans = 400000000;
|
||||||
|
for (int i = 1; i <= now; i++) {
|
||||||
|
if (p[i][0] != -1) {
|
||||||
|
int zhou = p[i][2] - p[i][0] + p[i][3] - p[i][1];
|
||||||
|
ans = mins(zhou * 2, ans);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cout << ans;
|
||||||
|
max()
|
||||||
|
}
|
BIN
4077_net/net.exe
Normal file
BIN
4077_net/net.exe
Normal file
Binary file not shown.
83
4077_net/net2.cpp
Normal file
83
4077_net/net2.cpp
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
#include <iostream>
|
||||||
|
using namespace std;
|
||||||
|
int n, now = 0, m, e[100001][2] = { 0 }, g[100001] = { 0 }, p[100001][4] = { 0 };
|
||||||
|
int mins(int a, int b)
|
||||||
|
{
|
||||||
|
return a < b ? a : b;
|
||||||
|
}
|
||||||
|
int maxs(int a, int b)
|
||||||
|
{
|
||||||
|
return a > b ? a : b;
|
||||||
|
}
|
||||||
|
void party(int a, int b)
|
||||||
|
{
|
||||||
|
//cout << a << " " << b << ":";
|
||||||
|
if (g[a] == 0 && g[b] == 0) {
|
||||||
|
g[a] = ++now;
|
||||||
|
g[b] = now;
|
||||||
|
int a0 = e[a][0], b0 = e[b][0], a1 = e[a][1], b1 = e[b][1];
|
||||||
|
p[now][0] = mins(a0, b0);
|
||||||
|
p[now][1] = mins(a1, b1);
|
||||||
|
p[now][2] = maxs(a0, b0);
|
||||||
|
p[now][3] = maxs(a1, b1);
|
||||||
|
} else {
|
||||||
|
while (p[g[a]][0] == -1) {
|
||||||
|
a = p[g[a]][3];
|
||||||
|
}
|
||||||
|
while (p[g[b]][0] == -1) {
|
||||||
|
b = p[g[b]][3];
|
||||||
|
}
|
||||||
|
if (g[a] > g[b]) {
|
||||||
|
int o = a;
|
||||||
|
a = b;
|
||||||
|
b = o;
|
||||||
|
}
|
||||||
|
//cout << g[a] << "?";
|
||||||
|
//cout << g[b] << "?" << endl;
|
||||||
|
if (g[a] == 0) {
|
||||||
|
g[a] = g[b];
|
||||||
|
int a0 = e[a][0], a1 = e[a][1];
|
||||||
|
p[g[b]][0] = mins(a0, p[g[b]][0]);
|
||||||
|
p[g[b]][1] = mins(a1, p[g[b]][1]);
|
||||||
|
p[g[b]][2] = maxs(a0, p[g[b]][2]);
|
||||||
|
p[g[b]][3] = maxs(a1, p[g[b]][3]);
|
||||||
|
} else {
|
||||||
|
if (g[a] != g[b]) {
|
||||||
|
p[g[b]][0] = mins(p[g[a]][0], p[g[b]][0]);
|
||||||
|
p[g[b]][1] = mins(p[g[a]][1], p[g[b]][1]);
|
||||||
|
p[g[b]][2] = maxs(p[g[b]][2], p[g[b]][2]);
|
||||||
|
p[g[b]][3] = maxs(p[g[b]][3], p[g[b]][3]);
|
||||||
|
p[g[a]][0] = -1, p[g[a]][3] = b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}/*
|
||||||
|
for (int i = 0; i <= 3; i++) {
|
||||||
|
cout << p[g[a]][i] << " ";
|
||||||
|
}
|
||||||
|
cout << endl;
|
||||||
|
for (int i = 0; i <= 3; i++) {
|
||||||
|
cout << p[g[b]][i] << " ";
|
||||||
|
}
|
||||||
|
cout << endl;*/
|
||||||
|
}
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
cin >> n;
|
||||||
|
for (int i = 1; i <= n; i++) {
|
||||||
|
cin >> e[i][0] >> e[i][1];
|
||||||
|
}
|
||||||
|
for (int i = 1; i <= m; i++) {
|
||||||
|
int yi, er;
|
||||||
|
cin >> yi >> er;
|
||||||
|
//cout << i << "||";
|
||||||
|
party(yi, er);
|
||||||
|
}
|
||||||
|
int ans = 400000000;
|
||||||
|
for (int i = 1; i <= now; i++) {
|
||||||
|
if (p[i][0] != -1) {
|
||||||
|
int zhou = p[i][2] - p[i][0] + p[i][3] - p[i][1];
|
||||||
|
ans = mins(zhou * 2, ans);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cout << ans;
|
||||||
|
}
|
1101
4077_net/test/In1 (15).txt
Normal file
1101
4077_net/test/In1 (15).txt
Normal file
File diff suppressed because it is too large
Load Diff
151
4077_net/test/In2 (7).txt
Normal file
151
4077_net/test/In2 (7).txt
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
100 50
|
||||||
|
68021018 99633766
|
||||||
|
14500838 58854042
|
||||||
|
51450250 22802942
|
||||||
|
54784284 18930959
|
||||||
|
21608488 37654461
|
||||||
|
6765135 61922596
|
||||||
|
44788924 92771206
|
||||||
|
31083598 42699356
|
||||||
|
18500113 22304435
|
||||||
|
85952847 8403454
|
||||||
|
15419962 49580744
|
||||||
|
20432110 68534702
|
||||||
|
34457257 57262432
|
||||||
|
73177440 80869451
|
||||||
|
97611886 29695171
|
||||||
|
94836299 65632904
|
||||||
|
81845289 61853489
|
||||||
|
24486946 33295539
|
||||||
|
37172784 31787582
|
||||||
|
4742850 58781272
|
||||||
|
69442043 11507986
|
||||||
|
20703868 66747319
|
||||||
|
4279192 4303818
|
||||||
|
9446676 75295657
|
||||||
|
26608253 47915875
|
||||||
|
36215463 42028215
|
||||||
|
97496619 9163925
|
||||||
|
63079269 31953877
|
||||||
|
18942709 36256709
|
||||||
|
65339680 16554595
|
||||||
|
18468232 12692331
|
||||||
|
82187500 313522
|
||||||
|
74545820 6674446
|
||||||
|
86125413 64234956
|
||||||
|
38462029 90868264
|
||||||
|
23016228 60420424
|
||||||
|
2376250 96236448
|
||||||
|
27167744 59171794
|
||||||
|
53056618 89130772
|
||||||
|
86983804 79664872
|
||||||
|
37046647 23199267
|
||||||
|
74209439 87059619
|
||||||
|
32363193 37288709
|
||||||
|
71529848 3822254
|
||||||
|
26061770 36869528
|
||||||
|
20376850 97046355
|
||||||
|
49561859 2564350
|
||||||
|
49876229 76624031
|
||||||
|
61755148 36001642
|
||||||
|
40858988 217177
|
||||||
|
26869906 16391568
|
||||||
|
13153954 81762508
|
||||||
|
65144369 40321698
|
||||||
|
40934303 18200987
|
||||||
|
29452470 27918107
|
||||||
|
50382211 19015469
|
||||||
|
3633726 77108003
|
||||||
|
58591440 88513271
|
||||||
|
66913064 30121288
|
||||||
|
92335526 45491186
|
||||||
|
66990816 12712376
|
||||||
|
42537541 69069027
|
||||||
|
67793078 44930122
|
||||||
|
45693059 29548226
|
||||||
|
80931765 39068399
|
||||||
|
29765404 60318023
|
||||||
|
55459967 42919358
|
||||||
|
42080532 73120688
|
||||||
|
35757408 35531187
|
||||||
|
91321676 17726230
|
||||||
|
63449294 94220239
|
||||||
|
89258051 19599372
|
||||||
|
71328242 47849492
|
||||||
|
8112644 38241306
|
||||||
|
77970780 52964522
|
||||||
|
83732493 97477949
|
||||||
|
65676898 78786386
|
||||||
|
19063328 33469976
|
||||||
|
23716509 64756387
|
||||||
|
63018202 57164626
|
||||||
|
56341138 45299958
|
||||||
|
17482649 64317458
|
||||||
|
40735668 59563181
|
||||||
|
37438146 29009428
|
||||||
|
47610720 81276174
|
||||||
|
46735658 11060014
|
||||||
|
75496414 88510062
|
||||||
|
83175739 46824656
|
||||||
|
36359554 43804735
|
||||||
|
37582315 14330334
|
||||||
|
96769257 73831160
|
||||||
|
64324635 14962507
|
||||||
|
52617546 83387964
|
||||||
|
48432483 76334055
|
||||||
|
660703 63967037
|
||||||
|
86015033 57001842
|
||||||
|
61783348 3497683
|
||||||
|
21319300 55035368
|
||||||
|
15577216 58757446
|
||||||
|
36561149 63187937
|
||||||
|
73 82
|
||||||
|
64 78
|
||||||
|
90 44
|
||||||
|
18 9
|
||||||
|
41 42
|
||||||
|
76 43
|
||||||
|
25 89
|
||||||
|
63 87
|
||||||
|
33 22
|
||||||
|
99 88
|
||||||
|
16 61
|
||||||
|
58 26
|
||||||
|
70 49
|
||||||
|
35 12
|
||||||
|
45 62
|
||||||
|
72 71
|
||||||
|
21 28
|
||||||
|
84 8
|
||||||
|
32 30
|
||||||
|
24 94
|
||||||
|
6 93
|
||||||
|
91 54
|
||||||
|
86 95
|
||||||
|
52 59
|
||||||
|
100 38
|
||||||
|
96 56
|
||||||
|
75 65
|
||||||
|
97 79
|
||||||
|
77 68
|
||||||
|
27 39
|
||||||
|
69 4
|
||||||
|
53 40
|
||||||
|
80 51
|
||||||
|
10 81
|
||||||
|
47 83
|
||||||
|
13 20
|
||||||
|
92 5
|
||||||
|
66 55
|
||||||
|
11 37
|
||||||
|
46 23
|
||||||
|
14 29
|
||||||
|
74 31
|
||||||
|
15 34
|
||||||
|
48 2
|
||||||
|
60 57
|
||||||
|
1 17
|
||||||
|
3 7
|
||||||
|
98 85
|
||||||
|
50 19
|
||||||
|
36 67
|
8
4077_net/test/in.txt
Normal file
8
4077_net/test/in.txt
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
3 2
|
||||||
|
|
||||||
|
6 7
|
||||||
|
8 6
|
||||||
|
8 4
|
||||||
|
|
||||||
|
1 2
|
||||||
|
3 2
|
14
4077_net/test/in3.txt
Normal file
14
4077_net/test/in3.txt
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
5 6
|
||||||
|
|
||||||
|
1 3
|
||||||
|
2 4
|
||||||
|
5 6
|
||||||
|
5 8
|
||||||
|
6 8
|
||||||
|
|
||||||
|
1 2
|
||||||
|
3 4
|
||||||
|
5 2
|
||||||
|
4 1
|
||||||
|
2 4
|
||||||
|
5 4
|
24
4077_net/test/out.txt
Normal file
24
4077_net/test/out.txt
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
## z:\Chao\src\4077_net\test\in.txt
|
||||||
|
2020/04/04 ÖÜÁù 12:33:42.43
|
||||||
|
10
|
||||||
|
-----------------------------------------------
|
||||||
|
Process exited after 240 ms with return value 0
|
||||||
|
|
||||||
|
## z:\Chao\src\4077_net\test\In1 (15).txt
|
||||||
|
2020/04/04 ÖÜÁù 12:33:42.43
|
||||||
|
389382416
|
||||||
|
-----------------------------------------------
|
||||||
|
Process exited after 120 ms with return value 0
|
||||||
|
|
||||||
|
## z:\Chao\src\4077_net\test\In2 (7).txt
|
||||||
|
2020/04/04 ÖÜÁù 12:33:42.43
|
||||||
|
26819096
|
||||||
|
-----------------------------------------------
|
||||||
|
Process exited after 110 ms with return value 0
|
||||||
|
|
||||||
|
## z:\Chao\src\4077_net\test\in3.txt
|
||||||
|
2020/04/04 ÖÜÁù 12:33:42.43
|
||||||
|
20
|
||||||
|
-----------------------------------------------
|
||||||
|
Process exited after 130 ms with return value 0
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user