Test instructions: Given a matrix, there is a polygon, which is the area of the polygon.
Analysis: Because it is in the lattice, and this polygon is very regular, so all the lattice is not all belong to the polygon is not belong to, or half, and we can according to the number of "/" and "\" to know, if it is odd, then is belong to,
An even number is not part of.
The code is as follows:
#pragma COMMENT (linker, "/stack:1024000000,1024000000") #include <cstdio> #include <string> #include < cstdlib> #include <cmath> #include <iostream> #include <cstring> #include <set> #include < queue> #include <algorithm> #include <vector> #include <map> #include <cctype> #include < cmath> #include <stack> #define Frer freopen ("In.txt", "R", stdin) #define Frew freopen ("OUT.txt", "w", stdout) Using namespace Std;typedef long Long ll;typedef pair<int, int> p;const int inf = 0x3f3f3f3f;const double INF = 0x3f 3f3f3f3f3f;const Double PI = ACOs ( -1.0); const double EPS = 1e-8;const int maxn = 1e2 + 5;const int mod = 1e9 + 7;const Cha R *mark = "+-*"; const int dr[] = {-1, 0, 1, 0};const int dc[] = {0, 1, 0, -1};const char *de[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};int N, M;const int Mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 31};const int monn[] = {0, h, H, H, H,, H, H,, H,, 31};inline int Min (int a, int b) {return a < ; B? A:B; }inline int Max (int a, int b) {return a > b a:b;} inline ll Min (ll A, ll b) {return a < b a:b;} inline ll Max (ll A, ll b) {return a > b a:b;} inline bool Is_in (int r, int c) {return R >= 0 && r < n && C >= 0 && C < m;} Char S[maxn];int main () {while (scanf ("%d%d", &n, &m) = = 2) {int ans = 0; for (int i = 0; i < n; ++i) {int cnt = 0; scanf ("%s", s); for (int j = 0; j < m; ++j) {if (s[j] = = '/' | | s[j] = = ' \ ') ++ans, ++cnt; else if (CNT & 1) ans + = 2; }} printf ("%d\n", ANS/2); } return 0;}
UVa 1641 ASCII Area (computational geometry, water problem)