栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

zoj 3528 Parterre

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

zoj 3528 Parterre

#pragma GCC optimize ("O2")#pragma comment(linker, "/STACK:16777216")#include <functional>#include <algorithm>#include <stdexcept>#include <iostream>#include <sstream>#include <fstream>#include <numeric>#include <iomanip>#include <cstdlib>#include <cstring>#include <utility>#include <cctype>#include <vector>#include <string>#include <bitset>#include <cmath>#include <queue>#include <stack>#include <ctime>#include <list>#include <map>#include <set>using namespace std;#define rep(i,a,b) for(int i=a;i<b;++i)#define repd(i,a,b) for(int i=a,_b=b;i>_b;--i)#define sz size()#define pb(x) push_back(x)#define TEST freopen("in","r",stdin);typedef long long ll;const int N = 255;int n, m;int nq, s;int ar[N];int ax1, ax2, ay1, ay2;int bx1, bx2, by1, by2;int cx1, cx2, cy1, cy2;int num[N];void deal() { int c, cnt = -1; memset(num, 0, sizeof (num)); rep(i, 1, s + 1) { ax1 = ay1 = i; ax2 = n + 1 - i; ay2 = m + 1 - i; cx1 = max(ax1, bx1); cy1 = max(ay1, by1); cx2 = min(ax2, bx2); cy2 = min(ay2, by2); if (cx1 > cx2 || cy1 > cy2) continue; int tn = 0, top = 0, left = 0, right = 0, bottom = 0; if (cx1 == ax1 || cx1 == ax2) { top = 1; tn += (cy2 - cy1) + 1; } if (cx2 != cx1 && (cx2 == ax1 || cx2 == ax2)) { bottom = 1; tn += (cy2 - cy1) + 1; } if (cy1 == ay1 || cy1 == ay2) { left = 1; tn += (cx2 - cx1) + 1; } if (cy2 != cy1 && (cy2 == ay1 || cy2 == ay2)) { right = 1; tn += (cx2 - cx1) + 1; } if (top) { if (left) -- tn; if (right) -- tn; } if (bottom) { if (left) -- tn; if (right) -- tn; } num[ar[i]] += tn; } int res = 0; for (int i = 1; i <= 250; ++i) { if (num[i]) ++ res; if (num[i] > cnt) { cnt = num[i]; c = i; } } printf("%d %d %dn", res, c, cnt);}int main() { while (cin >> n >> m) { s = min(n, m); s = (s + 1) / 2; rep(i, 1, s + 1) { scanf("%d", ar + i); } cin >> nq; rep(i, 0, nq) { scanf("%d%d%d%d", &bx1, &by1, &bx2, &by2); ++bx1; ++by1; ++bx2; ++by2; deal(); } }}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/372196.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号