ref

#include <algorithm>
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
int n, d[305], deg[1005];
vector<pair<int,int> > vec;
int main(){
cin>>n;
for(int i=1; i<=n; i++)
scanf("%d", &d[i]);
int l=1, r=n, q=d[n]+1, lst=0;
for(int i=1; i<=q; i++){
if(l<=r && q-i+deg[i]==d[r]){
lst = 1;
r--;
}
else if(l<=r && deg[i]==d[l]){
lst = 0;
l++;
}
if(lst){
for(int j=i+1; j<=q; j++){
deg[i]++; deg[j]++;
vec.push_back(make_pair(i,j));
}
}
}
cout<<vec.size()<<endl;
for(int i=0; i<vec.size(); i++)
printf("%d %d\n", vec[i].first, vec[i].second);
return 0;
}

cf976d Degree Set的更多相关文章

  1. Max Degree of Parallelism最大并行度配置

    由于公司的业务在急速增长中,发现数据库服务器已经基本撑不住这么多并发.一方面,要求开发人员调整并发架构,利用缓存减少查询.一方面从数据库方面改善并发.数据库的并行度可设置如下: 1)cost thre ...

  2. SQL Server数据库与max degree of parallelism参数

    我们今天主要向大家讲述的是SQL Server数据库中的max degree of parallelism参数,当 SQL Server 数据库在具N个微处理器或是 CPU 的计算机上运行时,它将为每 ...

  3. Oracle数据库作业-6 29、查询选修编号为“3-105“课程且成绩至少高于选修编号为“3-245”的同学的Cno、Sno和Degree,并按Degree从高到低次序排序。 select tname,prof from teacher where depart = '计算机系' and prof not in ( select prof from teacher where depart 。

    29.查询选修编号为"3-105"课程且成绩至少高于选修编号为"3-245"的同学的Cno.Sno和Degree,并按Degree从高到低次序排序. selec ...

  4. 关于索引degree设置的问题

    --并行查询 可以使用并行查询的情况 1. Full table scans, full partition scans, and fast full index scans 2. Index ful ...

  5. diameter - degree problem

    如今要构建一个网络模型,网络中的每一个节点最多和 d 个节点相连接, 且信息的传播从随意一个节点到另外随意一个节点的"最短路径" (路径依照单位路径算)都不能超过 k,问网络中最多 ...

  6. HDU 2454 Degree Sequence of Graph G(Havel定理 推断一个简单图的存在)

    主题链接:pid=2454">http://acm.hdu.edu.cn/showproblem.php?pid=2454 Problem Description Wang Haiya ...

  7. Misha and Palindrome Degree

    Misha and Palindrome Degree 题目链接:http://codeforces.com/problemset/problem/501/E 贪心 如果区间[L,R]满足条件,那么区 ...

  8. leetcode 697. Degree of an Array

    题目: Given a non-empty array of non-negative integers nums, the degree of this array is defined as th ...

  9. LeetCode 697. Degree of an Array (数组的度)

    Given a non-empty array of non-negative integers nums, the degree of this array is defined as the ma ...

随机推荐

  1. cf1040E. Network Safety(并查集)

    题意 题目链接 一张图,n个点,m条边,每个点有个权值x,x<=1e18.如果一条边的两个端点不一样,那么这条边是安全的,开始时所有边都是安全的. 现在有一个病毒y,病毒可以入侵任意的点,入侵一 ...

  2. 爱加密so保护简单脱壳测试

    1.   最近研究so文件的保护,在网上搜索发现爱加密支持对so文件的保护,然后联系客户,本来是想让客户保护一个自己的so文件来做测试的,结果客户各种不愿意,说要签什么XX协议后才能给so保护,各种蛋 ...

  3. 详细步骤教你安装yii高级应用程序和配置composer环境

    现在开始工作,应公司的要求,要开始接触yii了,作为一个没有碰过yii的小白,首先一个问题就是怎么去安装高级程序应用,过程不麻烦,但是也需要细心和耐心,百度资料里面的教程都不太全,漏这漏那的,所以在这 ...

  4. vuejs挂载点,模板与实例的关系

    <body> <div id='root'> <h1>{{msg}}</h1> </div> <script> new Vue( ...

  5. Python-Boolean operation

    一.布尔运算符 1.x and y: if x is false, then x, else y 2.x or y: if x is false, then y, else x 3.not x: if ...

  6. js表单序列化时,非空判断

    在项目中,对于数据的传输一般需要非空的判断,而数据字段较多时一般直接将表单序列化,此时如何判断非空,如下 因为将表单序列化时,数据格式为 trainKind=1&trainKindCode=1 ...

  7. 博学谷-数据分析numpy

    import numpy as  np print np.version.version np.array([1,2,3,4]) np.arange(15) np.array(range(10)) = ...

  8. 前端开发APP,从HBuilder开始~

    内容简介 介绍目前前端人员开发app的几种方法,具体介绍hbuilder开发app,一扇赞新的大门~ 无所不能的js 最开始js仅仅局限于网页上一些效果,操作网页内容等, 但是nodejs把js带入了 ...

  9. G++ 编译多个源文件

    g++ -c *.cpp g++ graph.o maxflow.o test.o -o test  // 链接顺序必须写对

  10. 用dom1来实现,根据光标移动自动给表单加上背景色,光标移开自动去除背景色

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