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

【题意】

在这里输入题意

【题解】

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

每次取最左边的线。

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

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

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

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

->然后作为新的x

【代码】

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. const int N = 100;
  4. int n;
  5. vector <int> v[N+10];
  6. int GetFirst(int temp){
  7. for (int i = temp;i <= n;i++)
  8. if (v[i].size()>0){
  9. return i;
  10. }
  11. return -1;
  12. }
  13. int main(){
  14. #ifdef LOCAL_DEFINE
  15. freopen("rush_in.txt", "r", stdin);
  16. #endif
  17. ios::sync_with_stdio(0),cin.tie(0);
  18. cin >> n;
  19. for (int i = 0;i <= n;i++)
  20. for (int j = 1;j <= n;j++){
  21. int y = i+j;
  22. if (y>n) break;
  23. v[i].push_back(y);
  24. }
  25. for (int i = 0;i <= n;i++){
  26. sort(v[i].begin(),v[i].end());
  27. reverse(v[i].begin(),v[i].end());
  28. }
  29. int cnt = 0;
  30. int x = GetFirst(0);
  31. while (x!=-1){
  32. cnt++;
  33. int y = v[x].back();
  34. v[x].pop_back();
  35. x = GetFirst(y);
  36. while (x!=-1){
  37. y = v[x].back();
  38. v[x].pop_back();
  39. x = GetFirst(y);
  40. }
  41. x = GetFirst(0);
  42. }
  43. cout << cnt << endl;
  44. return 0;
  45. }

【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. 79.express里面的app.configure作用

    以下摘自 express 3.0 的 文档 app.configure([env], callback) Conditionally invoke callback when env matches ...

  2. POJ 3256 DFS水题

    枚举点 每次都搜一遍 //By SiriusRen #include <cstdio> #include <cstring> #include <algorithm> ...

  3. 手动新建hive编程环境(以hive-1.0.0和hive-1.2.1为例)

    如下,是用maven构建项目,本篇博文重点不是这个.初学者(小白)变成小鸟后,建议开始用maven啦! Eclipse下Maven新建项目.自动打依赖jar包(包含普通项目和Web项目) HBase ...

  4. Codeforces 344C Rational Resistance

    Description Mad scientist Mike is building a time machine in his spare time. To finish the work, he ...

  5. 自己写unicode转换ascii码,wchar*到char*

    对于ascii码的char事实上就是unicode码wchar的首个字节码, 如wchar[20] = "qqqq"; 在内存中排码事实上是char的'q' '\0'这类.因此我们 ...

  6. Linux下Oracle的sqlplus中上下左右退格键无法使用

    一.配置yum源并安装readline* 配置本地yum 1.挂载光盘 mount /dev/cdrom /mnt/media 2,新建本地yun源的配置文件 vi /etc/yum.repos.d/ ...

  7. RvmTranslator6.3 is released

    RvmTranslator6.3 is released eryar@163.com RvmTranslator can translate the RVM file exported by AVEV ...

  8. es62

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

  9. Android图像处理之熔铸特效

    代码: package com.color; import android.content.Context; import android.graphics.Bitmap; import androi ...

  10. 42.管道,cmd执行指令写到管道中

    #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stdlib.h> #include <stri ...