【链接】 我是链接,点我呀:)

【题意】

在这里输入题意

【题解】

处理出所有的线
其实就是区间。
总共有n*(n+1)/2个
然后按照左端点、右端点排序

每次取最左边的线。

多种可能就取右端点尽量小的线。

v[i]i是左端点,里面的东西是右端点。

每个v[i]都从大到小排。

则每次取v[i]的最末端就可以了。

->然后作为新的x

【代码】

#include <bits/stdc++.h>
using namespace std; const int N = 100; int n;
vector <int> v[N+10]; int GetFirst(int temp){
for (int i = temp;i <= n;i++)
if (v[i].size()>0){
return i;
}
return -1;
} int main(){
#ifdef LOCAL_DEFINE
freopen("rush_in.txt", "r", stdin);
#endif
ios::sync_with_stdio(0),cin.tie(0);
cin >> n;
for (int i = 0;i <= n;i++)
for (int j = 1;j <= n;j++){
int y = i+j;
if (y>n) break;
v[i].push_back(y);
}
for (int i = 0;i <= n;i++){
sort(v[i].begin(),v[i].end());
reverse(v[i].begin(),v[i].end());
}
int cnt = 0;
int x = GetFirst(0);
while (x!=-1){
cnt++;
int y = v[x].back();
v[x].pop_back();
x = GetFirst(y);
while (x!=-1){
y = v[x].back();
v[x].pop_back();
x = GetFirst(y);
}
x = GetFirst(0);
}
cout << cnt << endl;
return 0;
}

【Codeforces Round #455 (Div. 2) B】Segments的更多相关文章

  1. 【Codeforces Round #455 (Div. 2) A】Generate Login

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 枚举两个串的前缀长度就好. 组出来. 排序. 取字典序最小的那个. [代码] #include <bits/stdc++.h& ...

  2. 【Codeforces Round #455 (Div. 2) C】 Python Indentation

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 一个for循环之后. 下一个写代码的地方一是从(x+1,y+1)开始的 然后如果写完了一个simple statement 下次就有 ...

  3. 【Codeforces Round #432 (Div. 1) B】Arpa and a list of numbers

    [链接]h在这里写链接 [题意] 定义bad list是一个非空的.最大公约数为1的序列.给定一个序列,有两种操作:花费x将一个元素删除.花费y将一个元素加1,问你将这个序列变为good list所需 ...

  4. 【Codeforces Round #420 (Div. 2) C】Okabe and Boxes

    [题目链接]:http://codeforces.com/contest/821/problem/C [题意] 给你2*n个操作; 包括把1..n中的某一个数压入栈顶,以及把栈顶元素弹出; 保证压入和 ...

  5. 【Codeforces Round #420 (Div. 2) B】Okabe and Banana Trees

    [题目链接]:http://codeforces.com/contest/821/problem/B [题意] 当(x,y)这个坐标中,x和y都为整数的时候; 这个坐标上会有x+y根香蕉; 然后给你一 ...

  6. 【Codeforces Round #420 (Div. 2) A】Okabe and Future Gadget Laboratory

    [题目链接]:http://codeforces.com/contest/821/problem/A [题意] 给你一个n*n的数组; 然后问你,是不是每个位置(x,y); 都能找到一个同一行的元素q ...

  7. 【Codeforces Round #423 (Div. 2) C】String Reconstruction

    [Link]:http://codeforces.com/contest/828/problem/C [Description] 让你猜一个字符串原来是什么; 你知道这个字符串的n个子串; 且知道第i ...

  8. 【Codeforces Round #423 (Div. 2) B】Black Square

    [Link]:http://codeforces.com/contest/828/problem/B [Description] 给你一个n*m的格子; 里面包含B和W两种颜色的格子; 让你在这个格子 ...

  9. 【Codeforces Round #423 (Div. 2) A】Restaurant Tables

    [Link]:http://codeforces.com/contest/828/problem/A [Description] 有n个组按照时间顺序来餐馆; 每个组由一个人或两个人组成; 每当有一个 ...

随机推荐

  1. TRIZ系列-创新原理-7-嵌套原理

    原理表述例如以下: 1)把一个物体嵌入另外一个物体.然后将这两个物体再嵌入第三个物体,以此类推. 这个原理又叫俄罗斯娃原理,目的是在不影响原有功能的情况下: A) 在须要时.能够降低系统的体积和便于携 ...

  2. mysql二进制日志文件出错导致mysql服务无法启动

    今天打开phpmyadmin发现连不上mysql数据库,重新启动mysql启动不起来,查看日志发现例如以下错误 <span style="font-family:SimSun;font ...

  3. vue5 过滤器 模版

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  4. Nios II 系统时钟timestamp的应用

    在用Nios II做外设时序驱动的时候,经常会用延时函数.有时会常使用某个FPGA芯片和时钟,比如笔者一直使用的芯片是cyclone系列 EP2C35F484C8N,PLL输入SOPC时钟是50M.因 ...

  5. ADO.NET数据读取封装

    public class sqlserver { //private string sqlstr = System.ConfigurationManager.ConnectionStrings[&qu ...

  6. 使用powerdesigner建模时设置主键自增的问题

    研究了一下,其实只要双击表,选择columns,再双击在你所要设为自增型的键上(比如你的id)或者右键选择Properties,弹出一个ColumnProperties 对话框,我们看到有标识 ide ...

  7. js获取当前时间年份,处理年月日

    js中获得当前时间年份.月份.日期       //获取完整的日期 var date=new Date; var y = date.getFullYear()var m = date.getMonth ...

  8. PatentTips - System and method to deprivilege components of a virtual machine monitor

    BACKGROUND INFORMATION An embodiment of the present invention relates generally to virtualization pl ...

  9. 检查类型是否包含iterator

  10. [Python] Understand Mutable vs. Immutable objects in Python

    In this lesson, you will learn what mutable and immutable objects are, and the difference between th ...