• Don't try so hard, the best things come when you least expect them to.
Don't try so hard, the best things come when you least expect them to.
展开全文
• So I might have an opportunity to hijack someone else's account by simply creating a new user with the same user name someone else has already use. I haven't tried this hack, but maybe we ...
• <div><p>anytime i try and edit any video about 4 minutes into it the whole programs crashed each and every time <ul><li>Operating System / windows 10 home</li><li>OpenShot Version2.4.2 laptop is a HP...
• <p>Whenever I try to draw something it takes me so much time to get the shapes and drawings where exactly I need them to be (things are not smooth compared to inkspace), and that is mostly because it ...
• <p>I want to re-assign some of the existing mappings to others that better suit my needs, but it is very hard to deduce which one the extension is using for each default keybinding, some are native ...
• <p>That list is in overviewer.permalinks, though I was thinking that hard permalinks should perhaps be generated by in-game signs using "#permalink-name" on the first or last line of the sign....
• This is the most tough task in this contest, do not try it until you solve all the other tasks or you feel boring on others. Given an undirected graph, you are to find out a subgraph of it so that the...
HDUOJ 3551 Hard Problem
题目链接
Problem Description
This is the most tough task in this contest, do not try it until you solve all the other tasks or you feel boring on others. Given an undirected graph, you are to find out a subgraph of it so that the degree of the i-th node in the subgraph is the given integer Di. The subgraph is a subset of edges and all vertexes are reserved. Notice that the graph may be disconnected, and two edges may connect the same vertexes, but no self cyclic exists.
Input
The input contains several test cases, the first line of the input contains an integer T denoting the number of test cases.
For each test case, the first line contains two integers N and M, denoting the number of vertexes and number of edges in the graph. (1 <= N <= 50, 1 <= M <= 200)
For the next M lines, each line contains two integers X and Y, denote there is a edge between X-th node and Y-th node. (1 <= X, Y <= N)
For the last N lines, each line contains a single integer Di, denote the degree of i-th node in the subgraph.
Output
For each test case, if the subgraph exist, output “YES”, otherwise output “NO”. See sample output for further details
Sample Input
2
4 4
1 2
3 4
2 3
1 4
1
2
1
0
4 5
2 1
1 2
2 3
3 4
3 4
1
0
1
0

Sample Output
Case 1: YES
Case 2: NO

一般图匹配，这题的精髓就是要加点加边进行构图，构图完成后用带花树算法判断是否是完全匹配即可~
下面来看如何构图，拿样例一：
首先根据每个点的度数加点：
$点1->1:1$
$点2->2:2,3$
$点3->1:4$
$点4->0$
然后将边重新编号，再将加的点与对应边的点连边：
$边1：1-2->5-6\ \ 连边：1-5\ \ 2-6\ \ 3-6$
$边2：3-4->7-8\ \ 连边：4-3$
$边3：2-3->9-10\ \ 连边：2-9\ \ 3-9\ \ 4-10$
$边4：1-4->11-12\ \ 连边：1-11$
这样一来图就重构完成了，下面就套模板判断是否是完全匹配即可：
#include <bits/stdc++.h>
using namespace std;
const int N=1e3+5;
deque<int>q;
bool G[N][N],g[N][N],inque[N],inblossom[N],vis[N];
int match[N],pre[N],base[N];
int n,m,t,u,v,d,id;
vector<int>V[N];
struct node{
int u,v;
}E[N];
int Find(int u,int v){
bool inpath[N]={false};
while(1){
u=base[u];
inpath[u]=true;
if(match[u]==-1)break;
u=pre[match[u]];
}
while(1){
v=base[v];
if(inpath[v])return v;
v=pre[match[v]];
}
}

void reset(int u,int anc){
while(u!=anc){
int v=match[u];
inblossom[base[u]]=1;
inblossom[base[v]]=1;
v=pre[v];
if(base[v]!=anc)pre[v]=match[u];
u=v;
}
}

void contract(int u,int v,int n){
int anc=Find(u,v);
memset(inblossom,0,sizeof(inblossom));
reset(u,anc);reset(v,anc);
if(base[u]!=anc)pre[u]=v;
if(base[v]!=anc)pre[v]=u;
for(int i=1;i<=n;i++)
if(inblossom[base[i]]){
base[i]=anc;
if(!inque[i]){
q.push_back(i);
inque[i]=1;
}
}
}

bool dfs(int s,int n){
for(int i=0;i<=n;i++)pre[i]=-1,inque[i]=0,base[i]=i;
q.clear();q.push_back(s);inque[s]=1;
while(!q.empty()){
int u=q.front();q.pop_front();
for(int v=1;v<=n;v++){
if(g[u][v]&&base[v]!=base[u]&&match[u]!=v){
if(v==s||(match[v]!=-1&&pre[match[v]]!=-1))contract(u,v,n);
else if(pre[v]==-1){
pre[v]=u;
if(match[v]!=-1)q.push_back(match[v]),inque[match[v]]=1;
else{
u=v;
while(u!=-1){
v=pre[u];
int w=match[v];
match[u]=v;
match[v]=u;
u=w;
}
return true;
}
}
}
}
}
return false;
}

void calculate()
{
int ans=0;
memset(match,-1,sizeof(match));
for(int i=1;i<=id-1;i++)
if(match[i]==-1&&dfs(i,id-1)) ans++;
if(ans*2==id-1) printf("YES\n");
else printf("NO\n");
}

void init(){
id=1;
memset(G,0,sizeof(G));
memset(g,0,sizeof(g));
for(int i=1;i<=n;i++) V[i].clear();
}

void build(){
for(int i=1;i<=m;i++){
for(auto k:V[E[i].u]) g[k][id]=g[id][k]=1;
id++;
for(auto k:V[E[i].v]) g[k][id]=g[id][k]=1;
g[id][id-1]=g[id-1][id]=1;
id++;
}
}

int main(){
scanf("%d",&t);
for(int p=1;p<=t;p++){
init();
scanf("%d%d",&n,&m);
for(int i=1;i<=m;i++){
scanf("%d%d",&u,&v);
G[u][v]=G[v][u]=1;
E[i].u=u,E[i].v=v;
}
for(int i=1;i<=n;i++){
scanf("%d",&d);
while(d--) V[i].push_back(id++);
}
build();
printf("Case %d: ",p);
calculate();
}
}



展开全文
• m betting this is gonna be a hard sell, so here's the pitch: - Touching a style tag after creation is bad. Really bad. After changing it, the DOM must parse the text, then evaluate the rules. ALL ...
• 16 is where I started to see artifacts...) with a variety of different fonts</li><li>[ ] This could be variable/env based so if you want a very high quality SDF you can set your settings that way...
• 1 command and I try moving any of the axes, I get the HARDLIMIT alarm, and i have to reset. If I try to use the homing feature, i get the same results. <p>I know the switches are wired correctly, i ...
• So instead of hard coding the namespace, some option would be to set the namespace in a config or just like Laravel <code>RouteServiceProvider</code> that uses <code>->namespace($this->... • <p>I noticed you pushed the 0.7.12 with Hardhat support so thought i'd give it a go and try to use. <p>Added 0.7.12, added to <code>hardhat.config.ts, and ran <code>hardhat coverage</code> and it ... • <p>This is my first try in golang, so I have no idea what I'm doing! ;-) Couldn't figure out the different use-cases in func needRefreshAppStatus, so I added the check for the new option at ... • Additionally when you try that in Mist, the final confirmation has not enough gas (even with the +100.000) , so one need to set it manually. <p>I would suggest to use the original contract: ... • This is the most tough task in this contest, do not try it until you solve all the other tasks or you feel boring on others. Given an undirected graph, you are to find out a subgraph of it so that the... • where broken down cars try and get to so they're not blocking traffic while they wait for service van). <p>Would it be possible to add an additional option (Policies tab in mod settings), ... • <div><p><code>CancellationTokenSource</code> is hard to use correctly, especially in concurrent scenarios. <p>Most CancellationTokenSource methods are booby-trapped with <code>ThrowIfDisposed, ... • As I am new to this field, could you provide me with some hints where start and maybe what to try... <p>my config is : Rafael Micro R820T tuner gr-osmosdr 0.1.4 (0.1.4) gnuradio 3.7.10 GNU C+&#... • <div><p>When trying to set up a new Photon through the CLI and letting it scan for WiFi networks it crashes with a hard fault in <code>wwd_scan_result_handler</code>. The Photon has firmware version ... • <div><p>I was working on a project the other day and evenually my debug builds started to become too large for the tiny microcontroller I was running on (an STM... so I decided to try setting <code>opt... • through solid blocks so that you can see it even if it mostly overlaps with the exiting build (eg ignore depth buffer while rendering the preview). <h3>Actual behaviour <p>It seems that once I click ... • Should I try to change all the connections, so that the 2-7 pins of the board would go to the driver's (something+) sockets and the (something-) sockets would be all connected to the GND pin ... • <div><p>I was alerted to this issue from a user in this issue https://automattic.helpshift.com/admin/issue/267452/ If you try to share a post from the WordPress app to Whatsapp, the blue color of the... • <p>Should we add a parameter to customize the maximum number of ~~line~~ statement or hardcode it to 1 line of code? 🤔 <p>Note that I'm not a native english speaker so please fix the rule... • <p>If you hardcode the VM name, this is the error you see: <pre><code>$ vagrant up WARN: Unresolved specs during Gem::Specification.reset: ffi (>= 1.0.11, ~> 1.0) net-ssh (< 2.8.0, >...
• <p>You can see the hard link structure is preserved, both files point to node 9452762649550924626. <p>However, when I try to restore the files, the hard link structure is not preserved: <pre><code> ...
• <p>Broadly, I think the right approach is probably to separate rearranging and content-editing into separate interfaces, so that you see a more condensed, trello-like view for arranging blocks, and no...
• Did you want to try searching another source? Also, if you want contribute these typings, please help us: https://github.com/typings/registry</code> that doesn't help so much. <p>Moreover, I get...

...