hunnu 11269 The Status is Not Quo (简单模拟)
来源:互联网 发布:常用的统计软件 编辑:程序博客网 时间:2024/05/22 05:26
http://acm.hunnu.edu.cn/online/?action=problem&type=show&id=11269
题意:
给一个n*m的格子,每个格子有八的端口与其它相连告诉你一些格子的内部
连接,最后给你线的一端,求另一端在哪里
思路:
很水很暴力。直接搜索就行,只是输入比较恶心,没有固定的连接数,要用
换行符来判断。
我的代码:
/*program:hunnu_11269author:BlackAndWhite*/ #include<stdio.h>#include<string.h>int n,m,i,j,js=1,ts;int a[405][10],ans0;char s,s1,ans1;void fun(int id,int num){ int t,bl=0; while(1) { t=a[id][num]; if(t==1||t==2)//枚举上面 { if(id-m<1) break; else {id-=m;num=7-t;} } if(t==3||t==4)//右面 { if(id%m==0) break; else {id++;num=11-t;} } if(t==5||t==6)//下面 { if(id+m>m*n) break; else {id+=m;num=7-t;} } if(t==7||t==8)//左面 { if((id-1)%m==0) break; else {id--;num=11-t;} } } ans0=id; ans1=t+'A'-1;}int main(){ while(scanf("%d%d",&n,&m),n||m) { printf("Board %d:\n",js++); memset(a,0,sizeof(a)); while(scanf("%d",&i)) { if(!i) break; while(scanf("%c",&s)) { if(s=='\n') break; if(s>='A'&&s<='z') { scanf("%c",&s1); a[i][0]++; a[i][s-'A'+1]=s1-'A'+1; a[i][s1-'A'+1]=s-'A'+1;//两个方向分别做个映射 } } } scanf("\n"); while(1) { scanf("%c",&s); if(s=='\n') break; if(s<='9'&&s>='0') { ts=s-'0'; while(scanf("%c",&s1)) { if(s1>='A'&&s1<='Z') break; ts=ts*10+s1-'0'; } fun(ts,s1-'A'+1); printf("%d%c is connected to %d%c\n",ts,s1,ans0,ans1); } } printf("\n"); } return 0;}
- hunnu 11269 The Status is Not Quo (简单模拟)
- HTTP Status 404(The requested resource is not available)
- HTTP Status 404(The requested resource is not available)
- HTTP Status 404 - The requested resource is not available.
- 论文原稿:Research on the Status Quo and System architecture of the Web Information Resource Evaluation
- HTTP Status 404(The requested resource is not available)的几种解决方法
- HTTP Status 404 /arcgis/rest: The requested resource (/arcgis/rest/) is not available
- HTTP Status 404(The requested resource is not available)的几种处理措施
- 1.HTTP Status 404(The requested resource is not available)的几种解决方案
- Tomcat 设置默认访问方式 HTTP Status 404(The requested resource is not available)解决方案
- HTTP Status 404(The requested resource is not available)的几种解决方法
- HTTP Status 404(The requested resource is not available)的几种解决方法
- struts2项目中:HTTP Status 404 - The requested resource is not available.
- 分享HTTP Status 404(The requested resource is not available)的几种解决方案
- HTTP Status 404 - The requested resource (/Test/loginSerlet) is not available.
- HTTP Status 404(The requested resource is not available)的几种解决方法
- HTTP Status 404 ,The requested resource (/struts2_test/login) is not available.
- form表单提交到servlet显示HTTP Status 404错误The requested resource is not available.
- 如何EXCEL中将英语单词按最后一个字母倒着排序
- Lightoj 1422 Halloween Costumes(区间DP)
- Codeforces #49 div2
- 实现两数 交换的三种不同编程方法。
- java基础问题
- hunnu 11269 The Status is Not Quo (简单模拟)
- 《妙趣横生的算法》第10章 算法设计与数据结构面试精粹之常见的算法设计题10-8(question?)
- 数据结构 线性表算法的实现
- 如何让QQ流氓不再扫描你的电脑
- CF 148D. Bag of mice
- delphi pchar char byte string转换问题
- C++ 初始化类的常量数据成员、静态数据成员、常量静态数据成员
- PVCBOT【17号A版】虫虫总动员--斗虫精灵家族
- C标准之间的差异