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个 ...
随机推荐
- SPREAD for Windows Forms 代码片段
'スクロールバーの移動 FpSpread1.ShowColumn(, , HorizontalPosition.Left) 'SetActiveCellの後.LeaveCellを呼び出す Dim ss ...
- grid响应式布局
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 接口请求json解析问题
今天同事问请求公司内部接口返回的json无法用json_decode解析,然后我让他把请求结果写入文件,然后文件发给我试试. 在打开这个文件之后我发现第一句话是 这是很令人奇怪的,为什么会出现一个双引 ...
- WAF Bypass数据库特性(Mysql探索篇)
0x01 背景 Mysql数据库特性探索,探索能够绕过WAF的数据库特性. 0x02 测试 常见有5个位置即: SELECT * FROM admin WHERE username = 1[位置一 ...
- ListView实现多种item布局的方法和注意事项
这篇文章的效果也是大家常见的,各种通讯应用的对话列表都是这种方式,像微信.whatsapp.易信.米聊等.我们这篇文章也权当为回忆,形成简单的笔记.这篇文章参考了2009年Google IO中的< ...
- [C] include <filename> 和 include "filename" 的区别
在 C 语言中包含语句 #include <filename> 和 #include "filename" 的区别在于编译器的偏好,一般来说,使用双引号表示优先搜索当前 ...
- 团购已满,O2O只是个笑话吗?
团购的用户习惯经过多年的“发酵”以后,大多数用户的团购习惯已经养成,同样一张电影票团购和直接现场购买的差价在一倍以上,当然O2O领域的其他情况也差不多,面对明显的“优惠”,用户当然乐意使用团购服务. ...
- Onpaint和OnDraw的区别
(一) OnPaint 和 OnDraw (1)OnPaint是WM_PAINT消息的消息处理函数,在OnPaint中调用OnDraw,一般来说,用户自己的绘图代码应放在OnDraw中. (2)OnP ...
- react设置多个className
在一个元素上设置样式,有一个固定的样式,然后还有一个使用三元运算符根据条件添加的样式. 比如说有一个固定样式"title": <div className="tit ...
- Tomcat的目录结构和配置文件详解
本文转载: https://www.zybuluo.com/1234567890/note/515235 参考帖子: Tomcat(一):基础配置详解 Tomcat服务器中配置多个域名,访问不同的we ...