当前位置:网站首页>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);
}
}
边栏推荐
- Haut OJ 1352: string of choice
- Solon Auth 认证框架使用演示(更简单的认证框架)
- Csp-j-2020-excellent split multiple solutions
- SSH password free login settings and use scripts to SSH login and execute instructions
- Under the national teacher qualification certificate in the first half of 2022
- Count sort
- 剑指 Offer 53 - II. 0~n-1中缺失的数字
- [merge array] 88 merge two ordered arrays
- 远程升级怕截胡?详解FOTA安全升级
- 使用Electron开发桌面应用
猜你喜欢
![[paper notes] multi goal reinforcement learning: challenging robotics environments and request for research](/img/17/db8614b177f33ee4f67b7d65a8430f.png)
[paper notes] multi goal reinforcement learning: challenging robotics environments and request for research

Embedded database development programming (zero)

支持多模多态 GBase 8c数据库持续创新重磅升级

lxml. etree. XMLSyntaxError: Opening and ending tag mismatch: meta line 6 and head, line 8, column 8

剑指 Offer 35.复杂链表的复制

Web APIs DOM node

A misunderstanding about the console window

挂起等待锁 vs 自旋锁(两者的使用场合)

2022年上半年国家教师资格证考试

一个新的微型ORM开源框架
随机推荐
Binary search basis
Shell Sort
每日一题-搜索二维矩阵ps二维数组的查找
TF-A中的工具介绍
Reflection summary of Haut OJ freshmen on Wednesday
Support multi-mode polymorphic gbase 8C database continuous innovation and heavy upgrade
Haut OJ 1350: choice sends candy
Add level control and logger level control of Solon logging plug-in
[sum of two numbers] 169 sum of two numbers II - enter an ordered array
质量体系建设之路的分分合合
一个新的微型ORM开源框架
读者写者模型
Haut OJ 1401: praise energy
A misunderstanding about the console window
object serialization
Animation scoring data analysis and visualization and it industry recruitment data analysis and visualization
26、 File system API (device sharing between applications; directory and file API)
sync. Interpretation of mutex source code
The next key of win generates the timestamp file of the current day
[allocation problem] 455 Distribute cookies