当前位置:网站首页>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;
}
边栏推荐
- Tutorial on the principle and application of database system (062) -- MySQL exercise questions: operation questions 32-38 (6)
- R language uses LM function to build multiple linear regression model, writes regression equation according to model coefficient, and uses conflict function to give 95% confidence interval of regressi
- Debezium series: major changes and new features of 2.0.0.beta1
- SQL daily practice (Niuke new question bank) - day 4: advanced operators
- 数据库系统原理与应用教程(062)—— MySQL 练习题:操作题 32-38(六)
- LyScript 获取上一条与下一条指令
- 数据库系统原理与应用教程(058)—— MySQL 练习题(二):单选题
- Denial of service DDoS Attacks
- 30天刷题训练(一)
- Jenkins--持续集成服务器
猜你喜欢

蓝桥集训(附加面试题)第七天

Countdown 2 days! 2022 China Computing Conference: Mobile cloud invites you to meet with computing network for innovative development

The domestic API management tool eolink is very easy to use, creating an efficient research and development tool

火山石投资章苏阳:硬科技,下一个10年相对确定的答案

Go language - Application of stack - expression evaluation

30天刷题计划(二)

Continuous (integration -- & gt; delivery -- & gt; deployment)

DXF读写:对齐尺寸标注文字居中、上方的位置计算

Better and more modern terminal tools than xshell!

After finishing, help autumn move, I wish you call it an offer harvester
随机推荐
算法---不同路径(Kotlin)
Beyond istio OSS -- current situation and future of istio Service Grid
产品经理:岗位职责表
No swagger, what do I use?
paddleClas分类实践记录
数据库系统原理与应用教程(059)—— MySQL 练习题:操作题 1-10(三)
Three men "running away" from high positions in the mobile phone factory
【黑马早报】字节估值缩水,降至2700亿美元;“二舅”视频作者回应抄袭;任泽平称取消商品房预售制是大势所趋;美联储宣布再加息75个基点...
Beyond Istio OSS——Istio服务网格的现状与未来
Rust 从入门到精通01-简介
数据库系统原理与应用教程(062)—— MySQL 练习题:操作题 32-38(六)
[C language] the difference between structure pointer and structure variable as formal parameters
微念“失去”李子柒的这一年
Jenkins--持续集成服务器
C语言:归并排序
.NET的求复杂类型集合的差集、交集、并集
Rust from introduction to mastery 01 introduction
111. SAP UI5 FileUploader 控件实现本地文件上传,接收服务器端的响应时遇到跨域访问错误
倒计时 2 天!2022 中国算力大会:移动云邀您共见算力网络,创新发展
DDoS protection with iptables