当前位置:网站首页>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);
}
}
边栏推荐
- [binary search] 34 Find the first and last positions of elements in a sorted array
- Acwing 4300. Two operations
- ssh免密登录设置及使用脚本进行ssh登录并执行指令
- [turn to] MySQL operation practice (III): table connection
- [interval problem] 435 Non overlapping interval
- [binary search] 69 Square root of X
- Es module and commonjs learning notes -- ESM and CJS used in nodejs
- Count sort
- Es module and commonjs learning notes
- Yolov5 adds attention mechanism
猜你喜欢
Binary search basis
Yolov5 adds attention mechanism
Fragment addition failed error lookup
SAP method of modifying system table data
To be continued] [UE4 notes] L4 object editing
Little known skills of Task Manager
[轉]: OSGI規範 深入淺出
Research on the value of background repeat of background tiling
[turn]: OSGi specification in simple terms
Pointnet++ learning
随机推荐
Shell Sort
Corridor and bridge distribution (csp-s-2021-t1) popular problem solution
Pointnet++ learning
Haut OJ 1357: lunch question (I) -- high precision multiplication
Add level control and logger level control of Solon logging plug-in
使用Room数据库报警告: Schema export directory is not provided to the annotation processor so we cannot expor
剑指 Offer 04. 二维数组中的查找
Embedded database development programming (V) -- DQL
Zzulioj 1673: b: clever characters???
Haut OJ 1218: maximum continuous sub segment sum
[trans]: spécification osgi
剑指 Offer 53 - I. 在排序数组中查找数字 I
Haut OJ 1401: praise energy
Csp-j-2020-excellent split multiple solutions
Solon Logging 插件的添加器级别控制和日志器的级别控制
Talking about JVM (frequent interview)
High precision subtraction
挂起等待锁 vs 自旋锁(两者的使用场合)
PMP考试敏捷占比有多少?解疑
Download xftp7 and xshell7 (official website)