Codeforces Round #677 (Div. 3) D/1433D Districts Connection
https://codeforces.com/contest/1433/problem/D
找两个不同权值的节点A、B连起来,所有与A不同权值的连到A上,相同的连到B上。
#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=5e3+100;
typedef long long LL;
LL a[maxn];
int main(void)
{
cin.tie(0);std::ios::sync_with_stdio(false);
LL t;cin>>t;
while(t--)
{
LL n;cin>>n;
for(LL i=1;i<=n;i++) cin>>a[i];
LL idx=-1;
vector<pair<LL,LL>>pr;
for(LL i=2;i<=n;i++)
{
if(a[i]!=a[1]){
pr.push_back({1,i});
idx=i;
}
}
if(idx==-1) {
cout<<"NO"<<endl;
continue;
}
else{
for(LL i=2;i<=n;i++)
{
if(a[i]==a[1]){
pr.push_back({idx,i});
}
}
cout<<"YES"<<endl;
for(auto i:pr){
cout<<(i.first)<<" "<<(i.second)<<endl;
}
}
}
return 0;
}
Codeforces Round #677 (Div. 3) D/1433D Districts Connection的更多相关文章
- Codeforces Round #677 (Div. 3) 题解
Codeforces Round #677 (Div. 3) 题解 A. Boring Apartments 题目 题解 简单签到题,直接数,小于这个数的\(+10\). 代码 #include &l ...
- Codeforces Round #677 (Div. 3)【ABCDE】
比赛链接:https://codeforces.com/contest/1433 A. Boring Apartments 题解 模拟即可. 代码 #include <bits/stdc++.h ...
- Codeforces Round #677 (Div. 3) D. Districts Connection思维1200
题目链接 Problem - 1433D - Codeforces 题目 美好的一天,从看不懂题目开始~~ Example input 4 5 1 2 2 1 3 3 1 1 1 4 1 1000 1 ...
- Codeforces Round #677 (Div. 3) E、G题解
E. Two Round Dances #圆排列 题目链接 题意 \(n\)(保证偶数)个人,要表演一个节目,这个节目包含两种圆形舞蹈,而每种圆形舞蹈恰好需要\(n/2\)个人,每个人只能跳一种圆形舞 ...
- Codeforces Round #677 (Div. 3) G. Reducing Delivery Cost(dijkstra算法)
题目链接:https://codeforces.com/contest/1433/problem/G 题解 跑 \(n\) 遍 \(dijkstra\) 得到任意两点间的距离,然后枚举哪一条边权为 \ ...
- Codeforces Round #677 (Div. 3)
F. Zero Remainder Sum || dp #include <cstdio> #include <algorithm> #include <cstring& ...
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
- Codeforces Round #368 (Div. 2)
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...
随机推荐
- 在windows下使用pip安装python包遇到缺失stdint.h文件的错误
今天在windows上使用pip安装一个python包python-lzf时遇到如下的错误: fatal error C1083: Cannot open include file: 'stdint. ...
- 我的Python自学之路-003 字符串的知识
'''字符串是以引号或者单引号括起来的任意文本,例如"123","asdfjk",'adfa'引号或者单引号,只是一种表示方法,并不是字符串的一部分如果字符串本 ...
- vue-ajax/axios请求函数封装: axios+promise
项目文件目录/src/api ajax.js /** * ajax 请求函数模块 * 返回值为promise对象 */ import axios from 'axios' export default ...
- Redis单机安装以及集群搭建
今天主要来看一下Redis的安装以及集群搭建(我也是第一次搭建). 环境:CentOS 7.1,redis-5.0.7 一.单机安装 1.将Redis安装包放置服务器并解压 2.进入redis安装目录 ...
- 关于KeePass实现ssh协议的自动登录
本文主要介绍一下,在keepass中如何实现linux主机的ssh方式的自动登录 keepass版本:KeePass 2.45 在keepass的URL中,其实默认也是内置了ssh的,其原理是调用pu ...
- lombok使用(给自己看的,只为不要忘记自己用过的技术)
如何使用? 一.1)eclipse使用方法 1. 从项目首页下载lombok.jar 2. 双击lombok.jar, 将其安装到eclipse中(该项目需要jdk1.6+的环境) 2)idea使用方 ...
- CSS3 新特性总结
1.边框 border-radius: 1-4 length|% / 1-4 length|%; 每个半径的四个值的顺序是:左上角,右上角,右下角,左下角.若省略左下角,和右上角相同,省略右下角,左上 ...
- django 的初始项目结构
2.创建Django项目 root@dev:shiyanlou_project# workon syl (syl) root@dev:shiyanlou_project# cd /aaa/shiy ...
- 第一个随笔 Just For Test, Nothing Else
第一个随笔 Just For Test, Nothing Else 注册了第一个博客,希望以后能添加点什么吧
- Nuget管理自己的项目库
Nuget是什么 Nuget 是一种 Visual Studio 扩展工具,它能够简化在 Visual Studio 项目中添加.更新和删除库(部署为程序包)的操作.(官方地址)相信大家对这个应该还是 ...