hdu 1050 Moving Table
来源:互联网 发布:在哪买淘宝号安全 编辑:程序博客网 时间:2024/05/17 08:24
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1050
很容猜到是用信心,但老是做不对,,,,郁闷!!!
首先要注意几点:
1。对数据的预先处理。
对于 (room 2 to room 3 ) and (room 4 to room 6), It's impossible move in once.
when room 2 to roo 3 ,it ocupy space 1 to 4.
So while room 4 to room 6. space 4 will be used by both.It's impossible.
2。下面就是排序了,按开始位置排序。
Game Over!
#include <iostream>#include <vector>#include <string>#include <algorithm>using namespace std;struct Node {int s, e;bool flag;bool operator <(const Node &elem) const {if(s!=elem.s)return s < elem.s;elsereturn e < elem.e;}} move[209];int main(int argc, char **argv) {//freopen("input.txt","r",stdin);int i, n, times, finished, T;cin >> T;while (T--) {cin >> n;for (i = 0; i < n; ++i) {cin >> move[i].s >> move[i].e;if (move[i].s > move[i].e)swap(move[i].s, move[i].e);if (move[i].s % 2 == 0)move[i].s--;if (move[i].e % 2 != 0)move[i].e++;move[i].flag = true;}sort(move, move + n);times = 0;while (true) {i = 0;while (!(move[i].flag) && i < n)++i;if (i < n) {move[i].flag = false;finished = move[i].e;++times;++i;} elsebreak;while(i<n){if (move[i].flag && finished < move[i].s){move[i].flag = false;finished=move[i].e;}++i;}}cout << 10 * times << endl;}return 0;}
- hdu 1050 Moving Table
- HDU 1050 moving table
- hdu moving table.
- 1050 moving table
- HDU 1050 Moving Tables
- hdu 1050 moving tables
- HDU-1050 Moving Tables
- hdu-1050-Moving Tables
- HDU 1050 Moving Tables
- HDU 1050 Moving Tables
- hdu 1050 moving tables
- hdu 1050 Moving Tables
- hdu 1050 Moving Tables
- hdu 1050 Moving Tables
- HDU (1050) Moving Tables
- HDU--1050 -- Moving Tables
- hdu 1050 Moving Tables
- hdu 1050 Moving Tables
- 与周鸿祎谈乔布斯
- MFC文件操作二
- 开发Android必备的java基础
- 回调函数以及钩子函数的概念
- 简单的TCP协议 socket编程(C语言版服务器和客户端)
- hdu 1050 Moving Table
- 大型网站后台架构的web server与缓存
- const char*, char const*, char*const的区别 .
- java中yield(),sleep()以及wait()的区别
- sizeof(结构体)和内存对齐
- 印度理工学院--亚洲大学的典范
- MFC 文件及其属性相关操作 (MFC 文件操作 三)
- 教学与自学
- C++ 简单的文件加密和解密 实例