# 一、D星群岛（全A，A了0.82的人考虑一下：四个岛，现在有两条桥1-2 3-4）

D星群岛由n个小岛组成。为了加强小岛居民之间的交流，头目决定启动一个造桥工程，将全部n个岛连接到一起。

2
3 3 400
1 2 200
1 3 300
2 3 500
3 3 400
1 2 500
1 3 600
2 3 700

Yes
No

## 代码：

package didi;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;

/**
* Created by IntelliJ IDEA.
*
* @Author:
* @Email:
* @Date: 2020/9/13
* @Time: 19:43
* @Version: 1.0
* @Description: Description
*/
public class First3 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int T = scanner.nextInt();
for (int l = 0; l < T; l++) {
int n = scanner.nextInt();
int m = scanner.nextInt();
int k = scanner.nextInt();
ArrayList<Integer[]> bridges = new ArrayList<>();
for (int i = 0; i < m; i++) {
Integer[] bridge = new Integer[2];
for (int j = 0; j < bridge.length; j++) {
bridge[j] = scanner.nextInt();
}
if (scanner.nextInt() <= k) {
}
}
/*if (bridges.size() < n - 1) {//三个岛最少也得有两座桥
System.out.println("No");
} else {
System.out.println("Yes"); //透风小技巧 只写这部分，不写下面的能A36%
}*/
HashSet<Integer> connections = new HashSet<Integer>();
if (!bridges.isEmpty()) {
bridges.remove(bridges.size() - 1);
}
while (true) {
boolean end = true;
for (int i = bridges.size() - 1; i > -1; i--) {
if (connections.contains(bridges.get(i)[0])
|| connections.contains(bridges.get(i)[1])) {
bridges.remove(i);
end = false;
}
}
if (end) {
break;
}
}
if (connections.size() == n) {
System.out.println("Yes");
} else {
System.out.println("No");
}
}
scanner.close();
}
}

# 二、毕业旅行（全A）

4 4
1 2 5
1 3 6
2 4 8
3 4 6
1 4 7.9/8

7.9/20

4 4
1 2 25
1 3 18
2 4 28
3 4 22
1 4 7.9/8

7.11/0

## 代码：

package didi;
import java.util.*;

/**
* Created by IntelliJ IDEA.
*
* @Author: 张志浩 Zhang Zhihao
* @Email: 3382885270@qq.com
* @Date: 2020/9/13
* @Time: 20:13
* @Version: 1.0
* @Description: Description
*/

public class Second2 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
int n = sc.nextInt();
int m = sc.nextInt();
List<int[]>[] ways = new List[n + 1];
for (int i = 0; i < n + 1; i++) {
ways[i] = new ArrayList<>();
}
for (int i = 0; i < m; i++) {
int l = sc.nextInt();
int r = sc.nextInt();
int cost = sc.nextInt();
int[] lr = {r, cost};
int[] rl = {l, cost};
}
int start = sc.nextInt();
int tar = sc.nextInt();
String time = sc.next();

int[] arrived = new int[n + 1];
Arrays.fill(arrived, Integer.MAX_VALUE);
while (!list.isEmpty()) {
int[] cur = list.poll();
int pos = cur[0];
int cost = cur[1];
if (cost < arrived[pos]) {
arrived[pos] = cost;
for (int[] arr : ways[pos]) {
if (arr[1] + cost < arrived[arr[0]]) {
}
}
}
}
int res = arrived[tar];
String out = help(res, time);
System.out.println(out);
}
}

static int[] months = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

public static String help(int res, String time) {
String[] temp = time.split("\\.");
int month = Integer.parseInt(temp[0]);
temp = temp[1].split("/");
int day = Integer.parseInt(temp[0]);
int hour = Integer.parseInt(temp[1]);

hour += res;
if (hour >= 24) {
day += hour / 24;
hour = hour % 24;
}
while (day > months[month]) {
day -= months[month];
month++;
}
StringBuilder arrive = new StringBuilder();
arrive.append(month).append(".")
.append(day).append("/").append(hour);

return arrive.toString();
}
}

# 最后

后续会分享更多纯干货文章，希望能真正帮到你们。你们的支持就是我最大的动力！欢迎关注点赞啊！

09-14 3万+

03-10 1万+
09-01 5867