题意 给你n*n的图,让你数正方形
题解:暴力for每个点,对于每个点从它出发顺时针走一个正方形。走完就ans[i]++;
坑:多输了一行******,然后在那里手摸样例,无限debug orz
#define _CRT_SECURE_NO_WARNINGS #include<cmath> #include<iostream> #include<stdio.h> #include<algorithm> #include<cstring> #include<ctime> using namespace std; #define rep(i,t,n) for(int i =(t);i<=(n);++i) #define per(i,n,t) for(int i =(n);i>=(t);--i) #define mmm(a,b) memset(a,b,sizeof(a)) typedef long long ll; const int maxn = 2e6 + 10; const ll mod = 1e9 + 7; void smain(); #define ONLINE_JUDGE int main() { //ios::sync_with_stdio(false); #ifndef ONLINE_JUDGE FILE *myfile; myfile = freopen("C:\Users\acm-14\Desktop\test\b.in", "r", stdin); if (myfile == NULL) fprintf(stdout, "error on input freopen "); FILE *outfile; outfile = freopen("C:\Users\acm-14\Desktop\test\out.txt", "w", stdout); if (outfile == NULL) fprintf(stdout, "error on output freopen "); long _begin_time = clock(); #endif smain(); #ifndef ONLINE_JUDGE long _end_time = clock(); printf("time = %ld ms.", _end_time - _begin_time); #endif return 0; } int n, m, k; int h[10][10], v[10][10]; int ans[10]; int tot; int check(int x) { int ret = 0; rep(i,1,n-x) rep(j, 1, n-x) { int nr = i, nc = j; int ok = 1; if (ok)rep(k, 1, x) { if (h[nr][nc])nc++; else ok = 0; } if (ok)rep(k, 1, x) { if (v[nr][nc])nr++; else ok = 0; } if (ok)rep(k, 1, x) { if (h[nr][nc-1])nc--; else ok = 0; } if (ok)rep(k, 1, x) { if (v[nr-1][nc])nr--; else ok = 0; } if (ok)ret++; } return ret; } void smain() { int kase = 0; int first = 1; while (cin >> n >> m) { if (first == 1)first = 0; else { cout << endl; puts("**********************************"); cout << endl; } mmm(h, 0); mmm(v, 0); mmm(ans, 0); while (m--) { char op; int r, c; cin >> op >> r >> c; if (op == 'H') { h[r][c] = 1; } else v[c][r] = 1; rep(i, 1, n) { ans[i]=check(i); } } printf("Problem #%d ", ++kase); int fl = 0; rep(i, 1, n)if (ans[i])fl++; if (!fl)printf("No completed squares can be found. "); else rep(i, 1, n)if (ans[i])printf("%d square (s) of size %d ", ans[i], i); } } /* */