Flag Day

Descriptions

小G请你对 n 个点进行染色,可选的颜色有三种:白、红、蓝,并使得给定的 m 个三元组中,每个点的颜色各不相同。

因为你可能不会三分图匹配,于是小G给出了更多的特殊条件:

  1. 每个点在三元组中至少出现一次,至多出现两次。
  2. 第 i 个(i ≥ 2)三元组中,至多有一个点在第 1 个到第 i-1 个三元组中出现过。

虽然这题现在已经很水了,但是小G为了照顾萌新,你只要输出其中任意一种方案即可。

Input

输入格式如下:
n m
a1 b1 c1
a2 b2 c2

am bm cm

其中, ai,bi,ci 表示一个三元组,其中的元素为第 ai,bi,ci 个点。

Output

输出格式如下:
c1 c2 … cn

其中, ci 表示第 i 个点的颜色, 1 表示白色, 2 表示红色, 3 表示蓝色。

Examples

Input
7 3
1 2 3
1 4 5
4 6 7
Output
1 2 3 3 2 2 1 
Input
9 3
3 6 9
2 5 8
1 4 7
Output
1 1 1 2 2 2 3 3 3 
Input
5 2
4 1 5
3 1 2
Output
2 3 1 1 3 
题目链接
 
题意 
同一行三个数字代表编号,例  

5 2
4 1 5
3 1 2

4号 1号 5号

3号 1号 2号

最后输出结果 1号 2号 3号 4号 5号

   分别为 2   3  1   1     3

4号 1号 5号

3号 1号 2号

分别对应 1 2 3

     1 2 3

即每一行都是这三个数字 不能重复,不能缺少

AC代码

#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define Mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x,y) memset(x,y,sizeof(x))
#define Maxn 100005
using namespace std;
int n,m;
int color[Maxn];
int a[];
int main()
{
cin>>n>>m;
MEM(color,);
for(int i=; i<m; i++)
{
cin>>a[]>>a[]>>a[];
if(i==)
{
color[a[]]=;
color[a[]]=;
color[a[]]=;
}
else
{
if(color[a[]]!=)
{
color[a[]]=(color[a[]]+);
color[a[]]=(color[a[]]+);
if(color[a[]]>)
color[a[]]-=;
if(color[a[]]>)
color[a[]]-=;
}
else if(color[a[]]!=)
{
color[a[]]=(color[a[]]+);
color[a[]]=(color[a[]]+);
if(color[a[]]>)
color[a[]]-=;
if(color[a[]]>)
color[a[]]-=;
}
else if(color[a[]]!=)
{
color[a[]]=(color[a[]]+);
color[a[]]=(color[a[]]+);
if(color[a[]]>)
color[a[]]-=;
if(color[a[]]>)
color[a[]]-=;
}
else
{
color[a[]]=;
color[a[]]=;
color[a[]]=;
}
}
}
for(int i=;i<=n;i++)
cout<<color[i]<<" ";
return ;
}

【CodeForces - 357B】Flag Day(水题)的更多相关文章

  1. Codeforces Gym 100531G Grave 水题

    Problem G. Grave 题目连接: http://codeforces.com/gym/100531/attachments Description Gerard develops a Ha ...

  2. codeforces 688A A. Opponents(水题)

    题目链接: A. Opponents time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  3. codeforces 706A A. Beru-taxi(水题)

    题目链接: A. Beru-taxi 题意: 问那个taxi到他的时间最短,水题; AC代码: #include <iostream> #include <cstdio> #i ...

  4. codeforces 569B B. Inventory(水题)

    题目链接: B. Inventory time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  5. Codeforces 489A SwapSort (水题)

    A. SwapSort time limit per test 1 second memory limit per test 256 megabytes input standard input ou ...

  6. CodeForces 534B Covered Path (水题)

    题意:给定两个速度,一个一初速度,一个末速度,然后给定 t 秒时间,还每秒速度最多变化多少,让你求最长距离. 析:其实这个题很水的,看一遍就知道怎么做了,很明显就是先从末速度开始算起,然后倒着推. 代 ...

  7. Codeforces Gym 100286I iSharp 水题

    Problem I. iSharpTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/ ...

  8. CodeForces 705A(训练水题)

    题目链接:http://codeforces.com/problemset/problem/705/A 从第三个输出中可看出规律, I hate that I love that I hate it ...

  9. CodeForces Gym 100685C Cinderella (水题)

    题意:给定 n 个杯子,里面有不同体积的水,然后问你要把所有的杯子的水的体积都一样,至少要倒少多少个杯子. 析:既然最后都一样,那么先求平均数然后再数一下,哪个杯子的开始的体积就大于平均数,这是一定要 ...

  10. CodeForces 931C Laboratory Work 水题,构造

    *这种题好像不用写题解... 题意: 一个人要改动别人的实验记录,实验记录记录是一个集合 实验记录本身满足:$max(X)-min(X)<=2$ 改动结果要求: 1.新的集合平均值和之前的一样 ...

随机推荐

  1. 使用mingw 对libcURL,openSSL,zLib交叉编译

    使用mingw 对libcURL,openSSL,zLib交叉编译   将三个库解压到同一目录下 比如取目录名为 "source" 的目录   提前安装active-perl 配置 ...

  2. 长江存储32层3D NAND今年底准备好,预计2020年赶上世界前沿(有些ppt很精彩)

    集微网消息(文/刘洋)2017年1月14日,首届IC咖啡国际智慧科技产业峰会暨ICTech Summit 2017在上海隆重举行.本次峰会以“匠心独运 卓越创‘芯’”为主题,集结了ICT产业领袖与行业 ...

  3. CentOS7中firewalld的安装与使用详解

    一.软件环境 [root@Geeklp201 ~]# cat /etc/redhat-release CentOS Linux release 7.4.1708 (Core) 二.安装firewall ...

  4. Oracle数据库备份和恢复的基本命令

    Oracle数据库备份与恢复基本命令 1. 获取帮助 $ exp help=y $ imp help=y 2.三种工作方式 (1)交互式方式 $ exp 然后按提示输入所需要的参数 (2)命令行方式 ...

  5. 统计插件,Highcharts,以及modelformset

    一.modelfromset组件 1.作用:用于批量处理多个表单 form表单对应的组件是formset Modelform对应的组件是modelformset 2.引入 From django.fo ...

  6. SYN5301型 毫秒表时间检定仪

       SYN5301型  毫秒表时间检定仪 频率记录仪时间记录仪时间频率信号的精密测量使用说明视频链接; http://www.syn029.com/h-pd-76-0_310_6_-1.html 请 ...

  7. 章节十四、8-javaScript弹框处理

    一.javaScript弹框没有id.也没有xpath,在F12开发者选项中无法直接通过鼠标去选择弹窗来确定元素在代码中的位置. 弹窗有两种,一种实只有"确定"按钮的alert类型 ...

  8. JDK JRE JVM 分别是什么

    JDK: Java Development Kit Java 开发工具包 JRE: Java Runtime Enviroment Java 运行时环境 JVM: Java Virtual Machi ...

  9. C++虚函数与虚表

    有一定面向对象知识的朋友对继承与多态一定很熟悉,C++想实现继承的话就要使用虚函数,那么什么是虚函数,其原理是什么,下面尽量给大家分析一下C++中其运行机制: 首先,基础,什么是虚函数,什么是多态? ...

  10. Appium+python自动化(十一)- 元素定位秘籍助你打通任督二脉 - 下卷(超详解)

    简介 宏哥看你骨骼惊奇,印堂发亮,必是练武之奇才! 按照上一篇的节目预告,这一篇还是继续由宏哥给小伙伴们分享元素定位,是不是按照上一篇的秘籍修炼,是不是感觉到头顶盖好像被掀开,内气从头上冒出去,顿时觉 ...