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;
} }
05-08 15:31