题:https://leetcode.com/problems/shortest-bridge/description/ 题目 In a given 2D binary array A, there are two islands. (An island is a 4-directionally connected group of 1s not connected to any other
A. Setting up Camp 题目分析: 有三种人,内向、外向、综合,内向必须独自一个帐篷,外向必须3个人一个帐篷,综合介于1~3人一个帐篷,我们发现非法情况只会存在外向的人凑不成3个人一个帐篷的情况,因外向不够可以向综合人借,故将二者合并并判断: #include<bits/stdc++.h>#pragma GCC optimize("Ofast")#define INF
1945A - Setting up Camp 题意:三种人安排住宿,a只能跟自己住,b只能三个人住,c能1~3个人,问最终最少房间数 思路:a单独安排,b放一起,不足三个人的用c补,然后c按照3人一房间尽可能分配 void solve() {int a , b , c;cin >> a >> b >> c;int ans = a +
Description The chess knight has a unique movement, it may move two squares vertically and one square horizontally, or two squares horizontally and one square vertically (with both forming the shape