当前位置:网站首页>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);
}
}
边栏推荐
- YOLOv5添加注意力機制
- 数仓项目的集群脚本
- [轉]: OSGI規範 深入淺出
- Gbase database helps the development of digital finance in the Bay Area
- [binary search] 34 Find the first and last positions of elements in a sorted array
- Talking about JVM (frequent interview)
- Reverse one-way linked list of interview questions
- Developing desktop applications with electron
- object serialization
- [sum of two numbers] 169 sum of two numbers II - enter an ordered array
猜你喜欢

Support multi-mode polymorphic gbase 8C database continuous innovation and heavy upgrade

YOLOv5-Shufflenetv2
![[to be continued] [depth first search] 547 Number of provinces](/img/c4/b4ee3d936776dafc15ac275d2059cd.jpg)
[to be continued] [depth first search] 547 Number of provinces

C语言杂谈1

读者写者模型

对象的序列化

sync. Interpretation of mutex source code

Pointnet++ learning

Reverse one-way linked list of interview questions

剑指 Offer 53 - II. 0~n-1中缺失的数字
随机推荐
[to be continued] I believe that everyone has the right to choose their own way of life - written in front of the art column
Shell Sort
[转]: OSGI规范 深入浅出
[merge array] 88 merge two ordered arrays
PMP candidates, please check the precautions for PMP examination in July
Solon Auth 认证框架使用演示(更简单的认证框架)
剑指 Offer 53 - I. 在排序数组中查找数字 I
Under the national teacher qualification certificate in the first half of 2022
Animation scoring data analysis and visualization and it industry recruitment data analysis and visualization
lxml. etree. XMLSyntaxError: Opening and ending tag mismatch: meta line 6 and head, line 8, column 8
To the distance we have been looking for -- film review of "flying house journey"
Drawing dynamic 3D circle with pure C language
[turn]: Apache Felix framework configuration properties
[allocation problem] 455 Distribute cookies
Embedded database development programming (zero)
Service fusing hystrix
[sum of two numbers] 169 sum of two numbers II - enter an ordered array
Pointnet++ learning
[转]MySQL操作实战(三):表联结
一个新的微型ORM开源框架