Codeforces 1196E Connected Component on a Chessboard
https://codeforces.com/contest/1196/problem/E
题解:贪心
/*
*@Author: STZG
*@Language: C++
*/
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
//#define DEBUG
#define RI register int
#define endl "\n"
using namespace std;
typedef long long ll;
//typedef __int128 lll;
const int N=100000+10;
const int M=100000+10;
const int MOD=1e9+7;
const double PI = acos(-1.0);
const double EXP = 1E-8;
const int INF = 0x3f3f3f3f;
int t,n,m,k,p,l,r,u,v;
int ans,cnt,flag,temp,sum;
int main()
{
#ifdef DEBUGfreopen("input.in", "r", stdin);//freopen("output.out", "w", stdout);
#endif//ios::sync_with_stdio(false);//cin.tie(0);//cout.tie(0);scanf("%d",&t);while(t--){int b,w;cin>>b>>w;if(b>3*w+1||w>3*b+1){cout<<"NO"<<"\n";}else {cout<<"YES"<<endl;int x = min(b,w);for(int i=0;i<2*x;i++){printf("%d %d\n",2,i+2);}b-=x;w-=x;for(int i=0;i<w;i++){if(i<x)printf("%d %d\n",1,2*i+3);else if(i<2*x)printf("%d %d\n",3,2*i+3-2*x);else printf("2 %d\n",2*x+2);}for(int i=0;i<b;i++){if(i<x)printf("%d %d\n",1,2*i+2);else if(i<2*x)printf("%d %d\n",3,2*i+2-2*x);else printf("2 1\n");}}}#ifdef DEBUGprintf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC);
#endif//cout << "Hello world!" << endl;return 0;
}
Codeforces 1196E Connected Component on a Chessboard相关推荐
- C++实现connected component连通分量(附完整源码)
C++实现connected component连通分量 C++实现connected component连通分量完整源码(定义,实现,main函数测试) C++实现connected compone ...
- C++用并查集Disjoint union实现connected component连通分量(附完整源码)
C++用并查集Disjoint union实现connected component连通分量 C++用并查集Disjoint union实现connected component连通分量完整源码(定义 ...
- LintCode Find the Weak Connected Component in the Directed Graph
原题链接在这里:http://www.lintcode.com/en/problem/find-the-weak-connected-component-in-the-directed-graph/ ...
- 翻译|How to Export a Connected Component
原文在这里:How to Export a Connected Component 根据你在export的不同,可以获得一个完美的函数式React-Redux connected组件,或者是一个完全忽 ...
- Connected component
活动地址:CSDN21天学习挑战赛 Undirected Graph An Undirected graph is connected if, for every pair nodes, th ...
- 【CodeForces - 1027B 】Numbers on the Chessboard (没有营养的找规律题,无聊题)
题干: You are given a chessboard of size n×nn×n. It is filled with numbers from 11 to n2n2 in the foll ...
- codeforces 1027 B - Numbers on the Chessboard(规律)
给一个n*n的数字矩阵 然后1到n^2/2的就从左到右 从上到下依次放在行列加起来是偶数的格子里 然后n^2/2+1的就放在奇数格子里 然后询问某个格子的数是多少 其实就是根据n是奇数还是偶数 还有询 ...
- 基础算法 —— 模拟思维
[概述] 模拟,是根据实际问题建立模型,模拟实际按程序走一遍,最终求出答案. 思维,则是与逻辑思维有关,其需要针对题意.数据范围等抽丝剥茧抽离出有用的信息,从而得出一个结果. 对于一般的模拟,直接根据 ...
- 【CodeForces - 920E】Connected Components? (dsu,补图连通块,STLset+map,bfs 或bitset)
题干: You are given an undirected graph consisting of n vertices and edges. Instead of giving you the ...
最新文章
- usaco Arithmetic Progressions
- 人月神话之阅读笔记01
- java对象的类型转换_Java对象的类型转换和属性复制
- 文献学习(part19)--Graph Connectivity In Sparse Subspace Clustering
- Linux 用户(user)和用户组(group)管理概述
- php 图片 3d旋转图片,html5实现图片的3D旋转效果
- 11.27 如何选择具有某一角色的当事人?
- json 反射java 实体_java反射实现javabean转json
- html中,怎么样才能获得iframe页面里的内容
- 7723java梦游游戏,渠道SDK登录
- hbase shell远程连接_HBase安装详解
- CodeForces - 556C Case of Matryoshkas
- 横向对比22款思维导图工具,最好用的我觉得是这款!
- 微信朋友圈点赞和评论测试用例
- 新版 OPPO Enco Free 2 固件工具 (仅供交流学习使用)
- FPGA 之 SOPC 系列(七)NIOS II 高级技术
- qq微信电脑客户端 for mac v1.0.0.6 官方版
- 深度学习之一---什么是神经网络
- 云计算------容器部署情感分析
- Python入门 判断用户输入的数是正数还是负数
热门文章
- sketch 将动图转换为json_开源 | Picasso:sketch设计稿智能解析工具
- qqkey获取原理_获取QQKEY源码[C++版]
- android 许可协议,Android 基本控件的使用二(注册许可协议)(CheckBox)
- mac怎么搭建php环境,Mac下快速搭建PHP开发环境
- 8类网线利弊_超6类网线和7类网线有何区别?有何用途?家用电脑,看这
- yii mysql语法_yii2 + mysql 常用增删改查操作语法以及事务
- 五、Hive数据类型和简单使用
- 期末复习、化学反应工程科目(第六、七章)
- pyqt5绘画API
- XAMPP的MYSQL无法启动 -This may be due to a blocked port, missing dependencies,