当前位置:网站首页>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);
}
}
边栏推荐
- Pointnet++学习
- Es module and commonjs learning notes -- ESM and CJS used in nodejs
- YOLOv5-Shufflenetv2
- 浅谈JVM(面试常考)
- kubeadm系列-02-kubelet的配置和启动
- 对象的序列化
- Warning using room database: schema export directory is not provided to the annotation processor so we cannot export
- Improvement of pointnet++
- [轉]: OSGI規範 深入淺出
- [depth first search] 695 Maximum area of the island
猜你喜欢
随机推荐
Haut OJ 1241: League activities of class XXX
PMP考试敏捷占比有多少?解疑
Pointnet++的改进
Programmers' experience of delivering takeout
[allocation problem] 455 Distribute cookies
object serialization
Using HashMap to realize simple cache
A preliminary study of sdei - see the essence through transactions
Haut OJ 1352: string of choice
Solution to the palindrome string (Luogu p5041 haoi2009)
GBase数据库助力湾区数字金融发展
kubeadm系列-00-overview
Haut OJ 1357: lunch question (I) -- high precision multiplication
Solon 框架如何方便获取每个请求的响应时间?
MySQL数据库(一)
Development error notes
剑指 Offer 09. 用两个栈实现队列
剑指 Offer 58 - II. 左旋转字符串
Double pointer Foundation
[sum of two numbers] 169 sum of two numbers II - enter an ordered array