傳送門
wireless network
time limit: 10000ms
memory limit: 65536k
total submissions: 30456
accepted: 12644
description
an earthquake takes place in southeast asia. the acm (asia cooperated medical team) have set up a wireless network with the lap computers, but an unexpected aftershock attacked, all computers in the network were all broken. the computers are repaired one by one, and the network gradually began to work again. because of the hardware restricts, each computer can only directly communicate with the computers that are not farther than d meters from it. but every computer can be regarded as the intermediary of the communication between two other computers, that is to say computer a and computer b can communicate if computer a and computer b can communicate directly or there is a computer c that can communicate with both a and b.
in the process of repairing the network, workers can take two kinds of operations at every moment, repairing a computer, or testing if two computers can communicate. your job is to answer all the testing operations.
input
the first line contains two integers n and d (1 <= n <= 1001, 0 <= d <= 20000). here n is the number of computers, which are numbered from 1 to n, and d is the maximum distance two computers can communicate directly. in the next n lines, each contains two integers xi, yi (0 <= xi, yi <= 10000), which is the coordinate of n computers. from the (n+1)-th line to the end of input, there are operations, which are carried out one by one. each line contains an operation in one of following two formats:
1. "o p" (1 <= p <= n), which means repairing computer p.
2. "s p q" (1 <= p, q <= n), which means testing whether computer p and q can communicate.
the input will not exceed 300000 lines.
output
for each testing operation, print "success" if the two computers can communicate, or "fail" if not.
sample input
sample output
source
poj monthly,hqm
題目大意
n台電腦都壞了。修好每台電腦隻能與它距離<=d的電腦聯系。
一些指令 有修好某台電腦,有詢問某兩台電腦能否聯通。
題解
并查集 當這台電腦修好時,周遊一遍它能到的電腦vi,如果vi修好了,
這兩台電腦加入一個集合中。
mmp在poj上交題 wa=絕望。一開始 ‘歐’看成‘0’,無限wa,然後字元串用
字元%c輸入的因為空格等無限wa,距離沒用double無限wa
╭(╯^╰)╮以後用字元數組
代碼