cf976d Degree Set
2024-08-29 11:28:05
#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;
}
最新文章
- win7-opengl开发环境的搭建
- Android Recovery Ui 分析
- ScrollView 的使用(非原创)
- DataTables warning 错误警告
- leetcode第29题--Substring with Concatenation of All Words
- haoce修改mysql
- POI导出多张图片到Excel
- AssetsUtils【读取assets、res/raw、./data/data/包名/目录下的文件】
- 配置Nginx部署静态资源和自动跳转到https
- Email发展历史
- [转帖]前端-chromeF12 谷歌开发者工具详解 Sources篇
- USART of STM32
- 在VS2017上使用C#调用非托管C++生成的DLL文件(图文讲解)
- FLIR ONE PRO热成像仪
- SendTo MD5 - imsoft.cnblogs
- 18年10月30日 NOIP模拟赛
- 【面试必读】一不注意就做错的五道JavaScript题目
- 部分函数依赖 &;&; 完全函数依赖
- Visual Basic 函数速查
- 带领技术小白入门——基于java的微信公众号开发(包括服务器配置、java web项目搭建、tomcat手动发布web项目、微信开发所需的url和token验证)