CCCC 排座位 图着色问题
1排座位:https://www.patest.cn/contests/gplt/L2-010
2图着色问题 https://www.patest.cn/contests/gplt/L2-023
建图XJB暴力的题目
1.
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
#include <math.h>
#include <string.h>
#include <string>
#include <map>
#include<stack>
#include<set>
#include<string.h>
#define pb push_back
#define _for(i, a, b) for (int i = (a); i<(b); ++i)
#define _rep(i, a, b) for (int i = (a); i <= (b); ++i) using namespace std;
const int N = + ;
//double num[N], price[N], ave[N];
int a[N][N]; int main() {
int n, m, k;
cin >> n >> m >> k;
memset(a, , sizeof(a));
_for(i, , m) {
int x, y, z;
cin >> x >> y >> z;
a[x][y] = a[y][x] = z;
}
_for(i, , k) {
int x, y;
cin >> x >> y;
if (a[x][y] == ) { cout << "No problem" << endl; continue; }
if(a[x][y]==) { cout << "OK" << endl; continue; }
int ok = ;
if (a[x][y] == -) {
_rep(q,,n)
{
if (a[x][q] && a[y][q]) { cout << "OK but..." << endl; ok = ; break; }
}
if (ok)cout << "No way" << endl;
}
}
system("pause");
}
2图着色:
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<vector>
#define _for(i, a, b) for (int i = (a); i<(b); ++i)
using namespace std;
typedef long long ll;
const int N = + ;
vector<int> E[N];
int p[N];
map<int, int> cnt;
int main() {
int v, e, k;
cin >> v >> e >> k;
_for(i, , e) {
int x, y;
cin >> x >> y;
E[x].push_back(y);
E[y].push_back(x);
}
int n;
cin >> n;
while (n--) {
cnt.clear();
_for(i, , v) {
cin >> p[i + ];
cnt[p[i + ]]++; }int ok = ;
if (cnt.size() != k)ok=; _for(i, , v) {
for (int j = ; j < E[i+].size(); j++) {
int now = E[i+][j];
if (p[i+] == p[now]) {
ok = ; break;
}
}
if (ok == )break; }
cout << (ok == ? "Yes" : "No") << endl;
} }
CCCC 排座位 图着色问题的更多相关文章
- CCCC L2-010. 排座位【并查集/分类讨论】
L2-010. 排座位 时间限制 150 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 陈越 布置宴席最微妙的事情,就是给前来参宴的各位宾客安排座位. ...
- CCCC L2-023. 图着色问题【set去重判不同种类个数/简单图论/判断两相邻点是否存在同色以及颜色个数】
L2-023. 图着色问题 时间限制 300 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 陈越 图着色问题是一个著名的NP完全问题.给定无向图 G ...
- 团体程序设计天梯赛-练习集L2-010. 排座位
L2-010. 排座位 时间限制 150 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 陈越 布置宴席最微妙的事情,就是给前来参宴的各位宾客安排座位. ...
- L2-010. 排座位
L2-010. 排座位 题目链接:https://www.patest.cn/contests/gplt/L2-010 并查集 相关题目:L2-007. 家庭房产,L3-003. 社交集群 下午打的时 ...
- PAT L2-023 图着色问题
https://pintia.cn/problem-sets/994805046380707840/problems/994805057298481152 图着色问题是一个著名的NP完全问题.给定无向 ...
- L2-023. 图着色问题*
L2-023. 图着色问题 参考博客 #include <iostream> #include <cstring> #include <set> using nam ...
- L2-010. 排座位(并查集)*
L2-010. 排座位 参考博客 #include<iostream> #include<math.h> using namespace std; ]; ][]; int fi ...
- [IOI2018] seats 排座位
[IOI2018] seats 排座位 IOI2018题解 压缩状态思想很不错的 每次把原来的贡献减掉,新来的再加上 最多涉及10个点 注意: 1.去重 2.下标从0开始 3.线段树初始的最小值个数都 ...
- pta l2-10(排座位)
题目链接:https://pintia.cn/problem-sets/994805046380707840/problems/994805066135879680 题意:给宴席排座位,有n个人,m个 ...
随机推荐
- Java使用泛型实现栈结构
泛型是Java SE5.0的重要特性,使用泛型编程可以使代码获得最大的重用.由于在使用泛型时要指明泛型的具体类型,这样就避免了类型转换.本实例将使用泛型来实现一个栈结构,并对其进行测试. 思路分析:既 ...
- 关联Left Outer Join的第一条记录
数据准备 CREATE TABLE person (person_id ), lastname )) / INSERT ALL INTO person (person_id, firstname, l ...
- JSP面试知识
JSP方面 1. JSP四种范围是什么?区别是什么? Page:指单单一页jsp page的范围: Request:的范围只在一jsp页发出请求到另一页之间,随后这个属性失效: Session:范围是 ...
- 【Postgres】PostgreSQL配置远程连接
1.开启相应的防火墙端口,缺省是5432 2.访问权限配置,D:\Program Files (x86)\PostgreSQL\9.2\data/pg_hba.conf中加入如下配置,开启远程访问 3 ...
- ckeditor 添加插件
官方插件包列表:https://ckeditor.com/cke4/addons/plugins/all 添加插件方法: 1)下载插件包(如果插件包有依赖其他插件,则依赖包也需要下载) 2)解压插件包 ...
- iOS开发-获取子视图坐标系中Point、Rect在父视图坐标系中的实际值
iOS提供了方法来完成上述值得转换 convertRect:toView:, convertRect:FromView: convertPoint:toView: and convertPoint:f ...
- wordpress for sae
帮人建个站,准备用sae+wordpess,小研究一下 http://sae.sina.com.cn/?m=apps&a=detail&aid=1 http://wp4sae.org/ ...
- Oracle和Mysql中mybatis模糊匹配查询区别
1.Oracle AND NAME LIKE '%'||#{name}||'%' 2.Mysql AND NAME LIKE "%"#{name}"%"
- java 对 汉字排序(按照拼音字母排序)
业务场景: 一个list集合,里面add了若干个实体类,针对该实体类排序的属性为String. 使用技术,自定义list排序(JDK自带),重写Comparator接口的compare方法,汉字转拼音 ...
- 《转》Robot Framework 的安装配置和简单的实例介绍
Robot Framework 介绍 Robot Framework 是一款基于 Python 的功能自动化测试框架.它具备良好的可扩展性,支持关键字驱动,可以同时测试多种类型的客户端或者接口,可以进 ...