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个 ...
随机推荐
- Images.xcassets 的简单使用
总结起来Images.xcassets 就这么几句话 (1)以下開始简单整理 进入images.xcassets 右键--->New Image Set 或者点XCode的images.xcas ...
- zabbix添加对tomcat线程池的监控
在zabbix模板中添加以下监控项: 可以参考文档:http://www.fblinux.com/?p=616
- Qt生成ui文件对应的.h和.cpp文件
在VS中,可以通过CMake设定QT5_WRAP_UI来编译a.ui到ui_a.h, 要想快速生成a.h和a.cpp,经过尝试,必须使用Qt Creator,否则就手写.
- 在eclipse里配置Android ndk环境 适用于windows mac 和linux(转)
在eclipse里配置Android ndk环境 适用于windows mac 和linux(转) 2012-02-27 13:02:16| 分类: android | 标签:java prog ...
- React Native(七)——react-native-elements
配合React native使用的UI库:https://react-native-training.github.io/react-native-elements/ 1. 新建项目:http://w ...
- JSON调试找不到 net.sf.ezmorph.Morpher
JSON中,java.lang.NoClassDefFoundError: net/sf/ezmorph/Morpher问题解决 使用JSON,在SERVLET或者STRUTS的ACTION中取得数据 ...
- Linux下Apache网站目录读写权限的设置
网站目录文件权限的设置对网站的安全至关重要,下面简单介绍网站目录文件权限的基本设定. 我们假设http服务器运行的用户和用户组是www,网站用户为centos,网站根目录是/home/centos/w ...
- php计算两个日期时间差(返回年、月、日)
在PHP程序中,很多时候都会遇到处理时间的问题,比如:判断用户在线了多长时间,共登录了多少天,两个帖子发布的时间差或者是不同操作之间的日志记录等等.在文章中,简单地举例介绍了PHP中如何计算两个日期相 ...
- xp下对dinput8.dll 游戏键盘输入的模拟 非函数hook
https://www.xuebuyuan.com/833929.html 很多游戏或者3d模拟软件为了更好的支持外设使用directinput作为输入接口调用.那么如果要模拟鼠标或键盘来控制游戏或者 ...
- No.4 PyQt学习(页面跳转)
先定义了两个MainWindow进行跳转,但发现这样的话,从第二个Window无法跳转会第一个.代码如下: # -*- coding: utf-8 -*- import sys from PyQt4. ...