题目描述 Due to recent rains, water has pooled in various places in Farmer John's field, which is represented by a rectangle of N x M (1 <= N <= 100; 1 <= M <= 100) squares. Each square contains either water ('W') or dry land ('.'). Farmer John wo…
题目链接 https://www.luogu.org/problemnew/show/P1596 题目描述 Due to recent rains, water has pooled in various places in Farmer John's field, which is represented by a rectangle of N x M (1 <= N <= 100; 1 <= M <= 100) squares. Each square contains eit…
P1596 [USACO10OCT]湖计数Lake Counting 题目描述 Due to recent rains, water has pooled in various places in Farmer John's field, which is represented by a rectangle of N x M (1 <= N <= 100; 1 <= M <= 100) squares. Each square contains either water ('W'…
https://www.luogu.org/problemnew/show/P1596 连通块水题... 大体思路是找到是水坑的坐标然后就开始不断递归,往八个方向搜,把连在一起的都标记一遍直到找不到为止 以下是本蒟蒻的代码 #include <bits/stdc++.h>//万能头 using namespace std; ][]; ]={,-,-,-,,,,,};//x方向 ]={,-,,,-,,-,,};//y方向 ; void dfs(int x,int y) { a[x][y]='.'…
\(problem\) 其实这题吧\(DFS\)好写一点(大雾 所以就不讲\(DFS\)了 em \(BFS\)的话 主要是 判重. 方向. 队列.(没了吧 至于位置 用两个队列?还是\(pair\)?还是结构体? \[\text{结构体大法好啊.emm}\] #ifdef Dubug #endif #include <bits/stdc++.h> using namespace std; typedef long long LL ; inline LL In() { LL res(0),f(…
可爱的题面君~~ 个人感觉这题还是很简单的,就是一个完全不加工的找联通块个数 个人解题思路是先读入,然后循环一遍,遇到水就dfs,并把这个w所在的联通块“删除”,并在答案上加一 最后输出答案 具体注释看程序::: #include<cmath> #include<cstdio> #include<iostream> #include<cstring> #include<algorithm> using namespace std; int n,m…
题目描述 Due to recent rains, water has pooled in various places in Farmer John's field, which is represented by a rectangle of N x M (1 <= N <= 100; 1 <= M <= 100) squares. Each square contains either water ('W') or dry land ('.'). Farmer John wo…
https://www.luogu.org/problemnew/solution/P2992 考虑包含原点,不包含原点的三角形有什么特征. 包含原点的三角形:任意找一个顶点和原点连线,一定能把另外两个顶点隔开到两侧. 不包含原点的:三个顶点中只有一个顶点满足:和原点连线后,能把另外两个顶点隔开到两侧. 因此我们统计这样的三点组(x,y,z)的数目:x和原点的连线能把y和z隔开在两侧. 一共C(n,3)个三角形,包含原点的贡献3个三点组,不包含的只贡献1个. 统计三点组的数目只需要把所有点按照极…
原题传送门 我们考虑进行容斥 包含原点的三角形个数=所有可能三角形的个数-不包含原点三角形的个数 对于每个点,我们会发现:将它与原点连线,在直线左边任选两点或右边任选两点与这个点构成的三角形一定是不包含原点的 对于每个点都这样计算,累加,会发现有算重复的(但不会少情况,自己画画图就民白了),所以每次只选这个点向量的半平面上的两个点 这样我们珂以对所有点进行极角排序,这样就珂以做到线性 代码中有几点要注意:1.特判点数小于3 \(\quad\) 2.long long #include <bits…
Lake Counting Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 49414   Accepted: 24273 Description Due to recent rains, water has pooled in various places in Farmer John's field, which is represented by a rectangle of N x M (1 <= N <= 10…