当前位置:网站首页>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);
}
}
边栏推荐
- 剑指 Offer 35.复杂链表的复制
- Haut OJ 1350: choice sends candy
- [to be continued] [UE4 notes] L1 create and configure items
- [转]: OSGI规范 深入浅出
- Haut OJ 1221: a tired day
- Haut OJ 1241: League activities of class XXX
- Binary search basis
- Csp-j-2020-excellent split multiple solutions
- 软件测试 -- 0 序
- Drawing dynamic 3D circle with pure C language
猜你喜欢

Remote upgrade afraid of cutting beard? Explain FOTA safety upgrade in detail
![[turn to] MySQL operation practice (III): table connection](/img/70/20bf9b379ce58761bae9955982a158.png)
[turn to] MySQL operation practice (III): table connection

Reader writer model

Service fusing hystrix

远程升级怕截胡?详解FOTA安全升级
![[to be continued] [UE4 notes] L1 create and configure items](/img/20/54ba719be2e51b7db5b7645b361e26.jpg)
[to be continued] [UE4 notes] L1 create and configure items

Fragment addition failed error lookup

Embedded database development programming (V) -- DQL

剑指 Offer 06.从头到尾打印链表

TF-A中的工具介绍
随机推荐
[to be continued] [depth first search] 547 Number of provinces
Warning using room database: schema export directory is not provided to the annotation processor so we cannot export
[to be continued] [UE4 notes] L1 create and configure items
kubeadm系列-02-kubelet的配置和启动
C language Essay 1
动漫评分数据分析与可视化 与 IT行业招聘数据分析与可视化
Bubble sort summary
FVP和Juno平台的Memory Layout介绍
Little known skills of Task Manager
[轉]: OSGI規範 深入淺出
每日一题-搜索二维矩阵ps二维数组的查找
lxml.etree.XMLSyntaxError: Opening and ending tag mismatch: meta line 6 and head, line 8, column 8
Bucket sort
PMP考试敏捷占比有多少?解疑
GBase数据库助力湾区数字金融发展
[binary search] 69 Square root of X
Yolov5 ajouter un mécanisme d'attention
服务熔断 Hystrix
Reader writer model
High precision subtraction