First Contact

题意

给定一个图,图中的点只有男的点或者女的点。给定两个不同的点AB,问他们第一个点通过两个不同的点找到第二个点,并且A找到的点和A同性,B连接的点跟B同性,这样的点对有多少对。

题解

暴力枚举即可,找到所有相邻的同性点,之后同性点之间有连接就是一对点对。

  • wa点 前导零输出,-0000输入

  • 中间的点不能是两边的点,必须是不同的四个点

ac代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include
using
#define
#define
#define
#define
typedef
typedef
const
//head
map
const
int
int
int
void
char
ch[0
ch[1
ch[2
ch[3
ch[4
int
while
ch[cnt--] = (x%10
x /= 10
}
printf
}
int
int
int
if
rep(i,1
a += pow
}
sign = 1
}else
rep(i,0
a += pow
}
}
return
}
int
#ifdef
freopen("1.in"
#endif
int
scanf
int
rep(i,0
string
int
int
x = trans(a,sign1) ; y = trans(b,sign2);
if
mx[x] = cnt++;
if
idx[mx[x]] = x;
}
if
mx[y] = cnt++;
if
idx[mx[y]] = y;
}
int
int
vis[id1][id2] = vis[id2][id1] = 1
}
int
rep(i,0
int
x = max(-1
y = max(-1
int
vector
if
puts
continue
}
rep(j,1
if
xx.push_back(j);
rep(j,1
if
yy.push_back(j);
vector
for
for
if
ans.push_back(make_pair
}
}
}
sort(ans.begin(),ans.end());
printf
for
output(x.fi); printf
puts
//printf("%d %d\n",x.fi,x.se);
}
}
return
}

[pat1139]First Contact 前导零

https://www.cheasim.com/pat/2019/08/28/pat1139-First-Contact-%E5%89%8D%E5%AF%BC%E9%9B%B6.html

作者 CheaSim

发布于 2019-08-28

更新于 2019-08-28

许可协议

#pat