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 排座位 图着色问题的更多相关文章

  1. CCCC L2-010. 排座位【并查集/分类讨论】

    L2-010. 排座位 时间限制 150 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 陈越 布置宴席最微妙的事情,就是给前来参宴的各位宾客安排座位. ...

  2. CCCC L2-023. 图着色问题【set去重判不同种类个数/简单图论/判断两相邻点是否存在同色以及颜色个数】

    L2-023. 图着色问题 时间限制 300 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 陈越 图着色问题是一个著名的NP完全问题.给定无向图 G ...

  3. 团体程序设计天梯赛-练习集L2-010. 排座位

    L2-010. 排座位 时间限制 150 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 陈越 布置宴席最微妙的事情,就是给前来参宴的各位宾客安排座位. ...

  4. L2-010. 排座位

    L2-010. 排座位 题目链接:https://www.patest.cn/contests/gplt/L2-010 并查集 相关题目:L2-007. 家庭房产,L3-003. 社交集群 下午打的时 ...

  5. PAT L2-023 图着色问题

    https://pintia.cn/problem-sets/994805046380707840/problems/994805057298481152 图着色问题是一个著名的NP完全问题.给定无向 ...

  6. L2-023. 图着色问题*

    L2-023. 图着色问题 参考博客 #include <iostream> #include <cstring> #include <set> using nam ...

  7. L2-010. 排座位(并查集)*

    L2-010. 排座位 参考博客 #include<iostream> #include<math.h> using namespace std; ]; ][]; int fi ...

  8. [IOI2018] seats 排座位

    [IOI2018] seats 排座位 IOI2018题解 压缩状态思想很不错的 每次把原来的贡献减掉,新来的再加上 最多涉及10个点 注意: 1.去重 2.下标从0开始 3.线段树初始的最小值个数都 ...

  9. pta l2-10(排座位)

    题目链接:https://pintia.cn/problem-sets/994805046380707840/problems/994805066135879680 题意:给宴席排座位,有n个人,m个 ...

随机推荐

  1. 5 -- Hibernate的基本用法 --4 1 创建Configuration对象

    org.hibernate.cfg.Configuration实例代表了应用程序到SQL数据库的配置信息,Configuration对象提供了一个buildSessionFactory()方法,该方法 ...

  2. [转]spring 官方下载地址(Spring Framework 3.2.x&Spring Framework 4.0.x)

    SPRING官方网站改版后,建议都是通过 Maven和Gradle下载,对不使用Maven和Gradle开发项目的,下载就非常麻烦,下给出Spring Framework jar官方直接下载路径: h ...

  3. ios开发之--复制到剪切板

    仅做记录: UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; pasteboard.string = @"你好&quo ...

  4. Win10 虚拟桌面

    我们可以建立多个桌面,各个桌面上运行的窗口任务互不干扰,这就是虚拟桌面 创建虚拟桌面:Win + Ctrl + D查看虚拟桌面:Win + Tab删除当前虚拟桌面:Win + Ctrl + F4切换到 ...

  5. C++ template —— 模板基础(一)

    <C++ Template>对Template各个方面进行了较为深度详细的解析,故而本系列博客按书本的各章顺序编排,并只作为简单的读书笔记,详细讲解请购买原版书籍(绝对物超所值).---- ...

  6. nsi脚本中执行.bat文件要隐藏dos窗口问题

    问题原因:工作中,在一个nsi的安装脚本文件中需要安装虚拟摄像头驱动,安装驱动脚本是.bat文件.使用nsi的execwait函数执行.bat文件时会显示dos窗口.但是领导要求不能显示dos窗口. ...

  7. 《转》Python学习(14)-对文件的操作(一)

    转自 http://www.cnblogs.com/BeginMan/p/3166644.html 一.文件对象 我理解的文件对象就是一个接口,通过这个接口对文件进行相关操作. <Python ...

  8. kafka---->kafka的使用(一)

    今天我们来学习一下kafka的简单的使用与配置.世上有可以挽回的和不可挽回的事,而时间经过就是一种不可挽回的事. kafka的安装配置 一.kafka的使用场景 活动跟踪:网站用户与前端应用程序发生交 ...

  9. Makefile 链接静态库

    Linux的静态库是以.a结尾的,要连接静态库有两种方法,一种是在编译命令最后直接加上库路径/库名称. 例如你的库在绝对目录/lib/libtest.a下面你就可以这样来编译$(CC) $(CFLAG ...

  10. Qt编写可拖动对象+背景地图+多种样式+多种状态(开源)

    在很多项目应用中,需要根据数据动态生成对象显示在地图上,比如地图标注,同时还需要可拖动对象到指定位置显示,能有多种状态指示,为此特意编写本控件,全部开源出来,欢迎大家提建议.同时多多支持整套自定义控件 ...