当前位置: 首页 > news >正文

网站建设栏目管理天眼查在线查询系统

网站建设栏目管理,天眼查在线查询系统,成都网站建设创意,文案策划公司题目链接如下: Online Judge 首先,我的代码虽然AC了,但是是有问题的,uva的测试数据太水了所以侥幸通过而已。因为题目要求的数据是实数而非整数,我的代码是按所有数据都是整数来暴力做的……但因为刘汝佳的代码写得太…

题目链接如下:

Online Judge

首先,我的代码虽然AC了,但是是有问题的,uva的测试数据太水了所以侥幸通过而已。因为题目要求的数据是实数而非整数,我的代码是按所有数据都是整数来暴力做的……但因为刘汝佳的代码写得太好了,我就懒得再抄一遍了;所以就把自己有问题的代码贴在这里。

正确的解法在这里(也是刘汝佳的思路):UVA ~ 221 ~ Urban Elevations (离散化)-CSDN博客

#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
// #define debug
const int maxx = 1000000;struct building{int x, y, width, depth, height, number;building(){}building(int _x, int _y, int _width, int _depth, int _height): x(_x), y(_y), width(_width), depth(_depth), height(_height){}
};
int n, x, y, width, depth, height, kase = 0;
std::vector<building> vec;
std::vector<int> ans[maxx];bool cmp1(const int &a, const int &b){return vec[a - 1].y < vec[b - 1].y;
}bool cmp2(const int &a, const int &b){return vec[a - 1].x != vec[b - 1].x ? vec[a - 1].x < vec[b - 1].x : (vec[a - 1].y < vec[b - 1].y);
}int main(){#ifdef debugfreopen("1.txt", "r", stdin);freopen("2.txt", "w", stdout);#endifwhile(scanf("%d", &n) == 1 && n){printf("%s", kase ? "\n" : "");printf("For map #%d, the visible buildings are numbered as follows:\n", ++kase);std::vector<int> tmp;fill(ans, ans + maxx, tmp);int maxWidth = 0;int minWidth = 10000000;vec.clear();for(int i = 1; i <= n; ++i){scanf("%d %d %d %d %d", &x, &y, &width, &depth, &height);vec.push_back(building(x, y, width, depth, height));vec.back().number = i;maxWidth = std::max(maxWidth, x + width);minWidth = std::min(minWidth, x);for(int j = x; j < x + width; ++j){ans[j].push_back(i);}}for(int i = minWidth; i < maxWidth; ++i){sort(ans[i].begin(), ans[i].end(), cmp1);int height = 0;for(int j = 0; j < ans[i].size(); ++j){if(vec[ans[i][j] - 1].height > height){height = vec[ans[i][j] - 1].height;} else{ans[i][j] = 0;}}}std::vector<int> res;std::set<int> st;for(int i = minWidth; i < maxWidth; ++i){for(int j = 0; j < ans[i].size(); ++j){if(ans[i][j] && st.find(ans[i][j]) == st.end()){res.push_back(ans[i][j]);st.insert(ans[i][j]);}}}sort(res.begin(), res.end(), cmp2);for(int i = 0; i < res.size(); ++i){printf("%d%s", res[i], i == res.size() - 1 ? "\n" : " ");}}#ifdef debugfclose(stdin);fclose(stdout);#endifreturn 0;
}

http://www.yayakq.cn/news/958809/

相关文章:

  • 单页面网站怎么做优化排名云南微网站搭建费用
  • 做电脑网站用什么软件自媒体平台注册账号下载
  • 做微信的网站叫什么软件潍坊网站建设wancet
  • 营销型网站的分类不包含wordpress固定链接设置自定义结构
  • 做机加工的网站有什么推荐的网站
  • 深圳苏州企业网站建设服务商品牌推广方案ppt
  • 网站导航网站排名关键词
  • 网站策划书免费可以做外贸的网站有哪些
  • 响应式网站代理wordpress slide插件
  • 建设网站的一般步骤怎么接网站建设的单子
  • 漂亮的flash网站微信微网站开发
  • 影视网站搭建哪个系统好古腾堡布局的网站
  • 网站推广与品牌建设佛山建设外贸网站公司吗
  • 网站qq临时会话买外链网站
  • 网站设计开发软件网页美化工具赣州带你飞网络科技有限公司
  • 企业微网站怎么建设wordpress建设网站的方法
  • wap手机商城网站源码wordpress国旗
  • vue企业门户网站模板个人网站建站系统
  • 广州建网站辽宁省住房和城乡建设厅网站进不去
  • 温州网站制作哪家好二级建造师兼职网
  • 找人做企业网站注意啥山东省建设厅网站 - 百度
  • 邯郸手机网站开发价格有做喜糖的网站吗
  • 视频网站开发视频dede 网站目录
  • 厦门公司做网站网络教育做的好的网站
  • 网站制作手机网站网站建设的难点在哪里
  • 规划设计 网站 网站结构佛山广告设计公司排名
  • 珠海网站建设的公司排名江西做网站
  • 网站收录量低怎么做职业生涯规划大赛报名
  • 营销型网站分为哪几种网站备案的规划方案
  • 网页制作免费网站百度网页版电脑版入口