【CodeForces - 357B】Flag Day(水题)
Flag Day
Descriptions
小G请你对 n 个点进行染色,可选的颜色有三种:白、红、蓝,并使得给定的 m 个三元组中,每个点的颜色各不相同。
因为你可能不会三分图匹配,于是小G给出了更多的特殊条件:
- 每个点在三元组中至少出现一次,至多出现两次。
- 第 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
Input7 3
1 2 3
1 4 5
4 6 7
Output1 2 3 3 2 2 1Input9 3
3 6 9
2 5 8
1 4 7Output1 1 1 2 2 2 3 3 3Input5 2
4 1 5
3 1 2
Output2 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(水题)的更多相关文章
- Codeforces Gym 100531G Grave 水题
Problem G. Grave 题目连接: http://codeforces.com/gym/100531/attachments Description Gerard develops a Ha ...
- codeforces 688A A. Opponents(水题)
题目链接: A. Opponents time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- codeforces 706A A. Beru-taxi(水题)
题目链接: A. Beru-taxi 题意: 问那个taxi到他的时间最短,水题; AC代码: #include <iostream> #include <cstdio> #i ...
- codeforces 569B B. Inventory(水题)
题目链接: B. Inventory time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- Codeforces 489A SwapSort (水题)
A. SwapSort time limit per test 1 second memory limit per test 256 megabytes input standard input ou ...
- CodeForces 534B Covered Path (水题)
题意:给定两个速度,一个一初速度,一个末速度,然后给定 t 秒时间,还每秒速度最多变化多少,让你求最长距离. 析:其实这个题很水的,看一遍就知道怎么做了,很明显就是先从末速度开始算起,然后倒着推. 代 ...
- Codeforces Gym 100286I iSharp 水题
Problem I. iSharpTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/ ...
- CodeForces 705A(训练水题)
题目链接:http://codeforces.com/problemset/problem/705/A 从第三个输出中可看出规律, I hate that I love that I hate it ...
- CodeForces Gym 100685C Cinderella (水题)
题意:给定 n 个杯子,里面有不同体积的水,然后问你要把所有的杯子的水的体积都一样,至少要倒少多少个杯子. 析:既然最后都一样,那么先求平均数然后再数一下,哪个杯子的开始的体积就大于平均数,这是一定要 ...
- CodeForces 931C Laboratory Work 水题,构造
*这种题好像不用写题解... 题意: 一个人要改动别人的实验记录,实验记录记录是一个集合 实验记录本身满足:$max(X)-min(X)<=2$ 改动结果要求: 1.新的集合平均值和之前的一样 ...
随机推荐
- Wiki上的C++哲学
Philosophy[edit] Throughout C++'s life, its development and evolution has been informally governed b ...
- Windows下获取高精度时间注意事项 [转贴 AdamWu]
花了很长时间才得到的经验,与大家分享. 1. RDTSC - 粒度: 纳秒级 不推荐优势: 几乎是能够获得最细粒度的计数器抛弃理由: A) 定义模糊 - 曾经据说是处理器的cycle counter, ...
- uni-app $refs的基本用法
$refs的基本用法 一个对象(Object),持有注册过 ref 特性 的所有 DOM 元素和组件实例. <template> <view class="containe ...
- 初次比较正式的IT职场面试后几点对自己web开发的思考
昨天晚上参加一个web开发面试,对于还没有真正毕业的自己来说,web开发的面试不是第一次,暑假就面试几家公司,前几次的面试并没有发现自己对自己学习的专业知识有什么学习态度的问题,因为前几次的面试官都是 ...
- git上如何处理无法clone和merge
对于一些需要FQ才能克隆下来的项目,我们需要使用代理 进入terminal: 设置代理: git config --global http.proxy http://127.0.0.1:1087 gi ...
- Spark学习之路(五)—— Spark运行模式与作业提交
一.作业提交 1.1 spark-submit Spark所有模式均使用spark-submit命令提交作业,其格式如下: ./bin/spark-submit \ --class <main- ...
- ZooKeeper学习之路(五)—— ACL权限控制
一.前言 为了避免存储在Zookeeper上的数据被其他程序或者人为误修改,Zookeeper提供了ACL(Access Control Lists)进行权限控制.只有拥有对应权限的用户才可以对节点进 ...
- jdk9新特性之jShell
jdk9还没研究完,结果jdk10都停止维护了. 最近回顾jdk9,发现了一个新特性--jShell. jdk9是在2017年的9月份发布的,这是我开始感觉入门java的时间.从jdk10开始就是半年 ...
- 【朝花夕拾】Android自定义View篇之(六)Android事件分发机制(中)从源码分析事件分发逻辑及经常遇到的一些“诡异”现象
前言 转载请注明,转自[https://www.cnblogs.com/andy-songwei/p/11039252.html]谢谢! 在上一篇文章[[朝花夕拾]Android自定义View篇之(五 ...
- 常用的方法论-5W2H