当前位置:网站首页>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);
}
}
边栏推荐
- [turn to] MySQL operation practice (I): Keywords & functions
- 发现一个很好的 Solon 框架试手的教学视频(Solon,轻量级应用开发框架)
- Haut OJ 1221: a tired day
- A preliminary study of sdei - see the essence through transactions
- Haut OJ 1357: lunch question (I) -- high precision multiplication
- To be continued] [UE4 notes] L4 object editing
- 记录QT内存泄漏的一种问题和解决方案
- [paper notes] multi goal reinforcement learning: challenging robotics environments and request for research
- Chapter 6 data flow modeling - after class exercises
- [es practice] use the native realm security mode on es
猜你喜欢
![[interval problem] 435 Non overlapping interval](/img/a3/2911ee72635b93b6430c2efd05ec9a.jpg)
[interval problem] 435 Non overlapping interval

Pointnet++的改进
![[转]: OSGI规范 深入浅出](/img/54/d73a8d3e375dfe430c2eca39617b9c.png)
[转]: OSGI规范 深入浅出
![[to be continued] [UE4 notes] L2 interface introduction](/img/0f/268c852b691bd7459785537f201a41.jpg)
[to be continued] [UE4 notes] L2 interface introduction

Little known skills of Task Manager

剑指 Offer 53 - II. 0~n-1中缺失的数字

Romance of programmers on Valentine's Day

Service fusing hystrix

Solution to the palindrome string (Luogu p5041 haoi2009)

Corridor and bridge distribution (csp-s-2021-t1) popular problem solution
随机推荐
The present is a gift from heaven -- a film review of the journey of the soul
[turn to] MySQL operation practice (I): Keywords & functions
剑指 Offer 53 - I. 在排序数组中查找数字 I
Haut OJ 1241: League activities of class XXX
剑指 Offer 09. 用两个栈实现队列
YOLOv5-Shufflenetv2
[depth first search] 695 Maximum area of the island
[转]MySQL操作实战(三):表联结
[to be continued] [depth first search] 547 Number of provinces
Pointnet++学习
[interval problem] 435 Non overlapping interval
Haut OJ 2021 freshmen week II reflection summary
剑指 Offer 58 - II. 左旋转字符串
剑指 Offer 35.复杂链表的复制
挂起等待锁 vs 自旋锁(两者的使用场合)
Haut OJ 1218: maximum continuous sub segment sum
[turn to] MySQL operation practice (III): table connection
【ES实战】ES上的native realm安全方式使用
支持多模多态 GBase 8c数据库持续创新重磅升级
使用Room数据库报警告: Schema export directory is not provided to the annotation processor so we cannot expor