当前位置:网站首页>Uva11175 digraph D and E from D to e and back
Uva11175 digraph D and E from D to e and back
2022-07-28 13:49:00 【bj_ hacker】
UVA11175 Directed graph D and E From D to E and Back Answer key
subject
link
https://www.luogu.com.cn/problem/UVA11175
Literal description
D It's a digraph , D Each side of corresponds to E A node of , if D Have edge uv, be E Node uv, about D The two sides of uv and vw, E Two nodes in uv And vw Even the edge . give E, Judge whether there is a corresponding D.
Ideas
I didn't understand the question for a long time at the beginning , Refer to the solution , Briefly talk about ideas
- enumeration 3 A little bit
- If the first two points have edges to the third point , Record 1
- If only one has , Record 2
- At the end of the third cycle, judge the record 1 And record 2 Does it exist at the same time
At the same time , error
otherwise , continue
This is because , Two points can go to multiple points at the same time , But suddenly there is a point that only one point can reach , This is the picture, so it can't be restored , So judge . - Finally, there was no error , correct
Code implementation
#include<bits/stdc++.h>
using namespace std;
const int maxn=300+10;
int n,m,k;
bool vis[maxn][maxn];
inline bool solve(){
for(int i=0;i<m;i++){
for(int j=0;j<m;j++){
bool flag1=false,flag2=false;
for(int k=0;k<m;k++){
if(vis[i][k]&&vis[j][k])flag1=true;
if(vis[i][k]^vis[j][k])flag2=true;
}
if(flag1&&flag2)return false;
}
}
return true;
}
int main(){
scanf("%d",&n);
int N=n;
while(n--){
printf("Case #%d: ",N-n);
memset(vis,false,sizeof(vis));
scanf("%d%d",&m,&k);
for(int i=1;i<=k;i++){
int x,y;
scanf("%d%d",&x,&y);
vis[x][y]=true;
}
if(solve())printf("Yes\n");
else printf("No\n");
}
return 0;
}
边栏推荐
- org.apache.ibatis.exceptions.TooManyResultsException的异常排查过程
- How to check if the interface cannot be adjusted? I didn't expect that the old bird of the 10-year test was planted on this interview question
- 面经整理,助力秋招,祝你称为offer收割机
- 不用Swagger,那我用啥?
- Cesium pit -- pit used by various API calls and API itself
- R language uses dpois function to generate Poisson distribution density data and plot function to visualize Poisson distribution density data
- 【黑马早报】字节估值缩水,降至2700亿美元;“二舅”视频作者回应抄袭;任泽平称取消商品房预售制是大势所趋;美联储宣布再加息75个基点...
- paddleClas分类实践记录
- Deployment之滚动更新策略。
- Using fail2ban to protect web servers from DDoS Attacks
猜你喜欢

使用 IPtables 进行 DDoS 保护

二舅能治好年轻人的精神内耗吗?

Half wave rectification light LED

30天刷题训练(一)

I miss the year of "losing" Li Ziqi

拒绝服务 DDoS 攻击

基于神经网络的帧内预测和变换核选择

Strict mode -- let and const -- arrow function -- Deconstruction assignment -- string template symbol -- set and map -- generator function

算法---不同路径(Kotlin)

Volcanic stone investment Zhang Suyang: hard technology, the relatively certain answer in the next 10 years
随机推荐
R语言ggplot2可视化:使用ggpubr包的ggviolin函数可视化小提琴图、设置palette参数自定义不同水平小提琴图的边框颜色
Is azvudine, a domestic oral new coronal drug, safe? Expert authority interpretation
记一次使用pdfbox解析pdf,获取pdf的关键数据的工具使用
合并表格行---三层for循环遍历数据
Merge table rows - three levels of for loop traversal data
DOJNOIP201708奶酪题解
[ecmascript6] function and its related use
POJ3275 Ranking the Cows题解
产品经理:岗位职责表
C language: random number + quick sort
LyScript 获取上一条与下一条指令
我秃了!唯一索引、普通索引我该选谁?
C language: quick sorting of sequential storage structure
Facial expression recognition based on pytorch convolution - graduation project "suggestions collection"
Holes in [apue] files
Volcanic stone investment Zhang Suyang: hard technology, the relatively certain answer in the next 10 years
Denial of service DDoS Attacks
What if the server cannot be connected (the original server cannot find the target resource)
JWT 登录认证 + Token 自动续期方案,写得太好了!
POJ1860货币兑换题解