博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
zoj 2475 Benny's Compiler
阅读量:4036 次
发布时间:2019-05-24

本文共 2306 字,大约阅读时间需要 7 分钟。

1、

2、题目大意:

题目给了一个图,包含各边的关系,现在 要看一个点是否在一个环内,若在输出no,不在输出yes,

dfs(),如果搜到重复的点,说明在环内,否则不在

3、题目:

Benny's Compiler

Time Limit: 2 Seconds     
Memory Limit: 65536 KB

These days Benny has designed a new compiler for C programming language. His compilation system provides a compiler driver that invokes the language preprocessor, compiler, assembler and linker. C source file (with .C suffix) is translated to relocatable object module first, and then all modules are linked together to generate an executable object file.

The translator (preprocessor, compiler and assembler) works perfectly and can generate well optimized assembler code from C source file. But the linker has a serious bug -- it cannot resolve global symbols when there are circular references. To be more specific, if file 1 references variables defined in file 2, file 2 references variables defined in file 3, ... file n-1 references variables defined in file n and file n references variables defined in file 1, then Benny's linker walks out because it doesn't know which file should be processed first.

Your job is to determine whether a source file can be compiled successfully by Benny's compiler.

Input

There are multiple test cases! In each test case, the first line contains one integer N, and then N lines follow. In each of these lines there are two integers Ai and Bi, meaning that file Ai references variables defined in file Bi (1 <= i <= N). The last line of the case contains one integer E, which is the file we want to compile.

A negative N denotes the end of input. Else you can assume 0 < N, Ai, Bi, E <= 100.

Output

There is just one line of output for each test case. If file E can be compiled successfully output "Yes", else output "No".

Sample Input

4

1 2
2 3
3 1
3 4
1

4

1 2
2 3
3 1
3 4
4

-1

Sample Output

No
Yes

4、AC代码:

#include
#include
int map[105][105];int vis[105];int flag,n;void dfs(int a){ for(int i=1;i<=n;i++) { if(vis[i]==1 && map[a][i]==1) { flag=0; return ; } if(map[a][i]==1) { vis[i]=1; dfs(i); vis[i]=0; } }}int main(){ int a,b; while(scanf("%d",&n)!=EOF) { if(n==-1) break; memset(map,0,sizeof(map)); memset(vis,0,sizeof(vis)); for(int i=0; i

转载地址:http://reddi.baihongyu.com/

你可能感兴趣的文章
简单Linux C线程池
查看>>
内存池
查看>>
输入设备节点自动生成
查看>>
opencv test code-1
查看>>
eclipse 导入先前存在的项目
查看>>
GNU hello代码分析
查看>>
Qt继电器控制板代码
查看>>
wpa_supplicant控制脚本
查看>>
rfkill: WLAN hard blocked
查看>>
gstreamer相关工具集合
查看>>
arm 自动升级脚本
查看>>
RS232 四入四出模块控制代码
查看>>
gstreamer插件之 videotestsrc
查看>>
autoupdate script
查看>>
linux 驱动开发 头文件
查看>>
/etc/resolv.conf
查看>>
container_of()传入结构体中的成员,返回该结构体的首地址
查看>>
linux sfdisk partition
查看>>
ipconfig,ifconfig,iwconfig
查看>>
opensuse12.2 PL2303 minicom
查看>>