当前位置:网站首页>Codeforces round 712 (Div. 2) d. 3-coloring (construction)
Codeforces round 712 (Div. 2) d. 3-coloring (construction)
2022-07-05 05:27:00 【solemntee】
We know that if the diagonal grid is completely painted with one color , The rest can be painted casually .( Imagine if the slashes cross and fill 1, Then the position of the gap should not be written 2 Or write 3, Women can't stop us )
So we use 1 Paint the main diagonal grid , use 2 De paint sub diagonal grid . There must be one filled first . Then paint casually !
The diagonal line is the main diagonal grid
ac Code
#include<bits/stdc++.h>
using namespace std;
char a[300005];
struct edge
{
int x,y;
};
queue<edge>q1,q2;
int main()
{
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
{
if((i+j)%2==0)q1.push({
i,j});
else q2.push({
i,j});
}
for(int i=1;i<=n*n;i++)
{
int t;
scanf("%d",&t);
/// If t yes 1, We will use 2 Desmear q2( Store the sub diagonal grid )
/// If the sub diagonal grid is full , Just paint casually in the main diagonal grid
if(t==1)
{
if(!q2.empty())
{
edge p=q2.front();
q2.pop();
printf("2 %d %d\n",p.x,p.y);
}
else
{
edge p=q1.front();
q1.pop();
printf("3 %d %d\n",p.x,p.y);
}
}
else if(t==2)
{
if(!q1.empty())
{
edge p=q1.front();
q1.pop();
printf("1 %d %d\n",p.x,p.y);
}
else
{
edge p=q2.front();
q2.pop();
printf("3 %d %d\n",p.x,p.y);
}
}
else if(t==3)
{
if(!q1.empty())
{
edge p=q1.front();
q1.pop();
printf("1 %d %d\n",p.x,p.y);
}
else
{
edge p=q2.front();
q2.pop();
printf("2 %d %d\n",p.x,p.y);
}
}
fflush(stdout);
}
}
边栏推荐
- Reader writer model
- C language Essay 1
- Acwing 4300. Two operations
- [转]MySQL操作实战(三):表联结
- Solon Logging 插件的添加器级别控制和日志器的级别控制
- Add level control and logger level control of Solon logging plug-in
- ssh免密登录设置及使用脚本进行ssh登录并执行指令
- 【ES实战】ES上的native realm安全方式使用
- Support multi-mode polymorphic gbase 8C database continuous innovation and heavy upgrade
- Romance of programmers on Valentine's Day
猜你喜欢
YOLOv5添加注意力机制
Binary search basis
lxml.etree.XMLSyntaxError: Opening and ending tag mismatch: meta line 6 and head, line 8, column 8
Solution to the palindrome string (Luogu p5041 haoi2009)
[paper notes] multi goal reinforcement learning: challenging robotics environments and request for research
SAP method of modifying system table data
质量体系建设之路的分分合合
远程升级怕截胡?详解FOTA安全升级
[轉]: OSGI規範 深入淺出
[转]MySQL操作实战(一):关键字 & 函数
随机推荐
Service fusing hystrix
SSH password free login settings and use scripts to SSH login and execute instructions
Acwing 4300. Two operations
[sum of two numbers] 169 sum of two numbers II - enter an ordered array
记录QT内存泄漏的一种问题和解决方案
发现一个很好的 Solon 框架试手的教学视频(Solon,轻量级应用开发框架)
动漫评分数据分析与可视化 与 IT行业招聘数据分析与可视化
National teacher qualification examination in the first half of 2022
sync.Mutex源码解读
Talking about JVM (frequent interview)
SAP method of modifying system table data
kubeadm系列-00-overview
object serialization
Web APIs DOM节点
Yolov5 ajouter un mécanisme d'attention
Haut OJ 1245: large factorial of CDs --- high precision factorial
Double pointer Foundation
C语言杂谈1
How can the Solon framework easily obtain the response time of each request?
kubeadm系列-02-kubelet的配置和启动