noip2011初赛-子矩阵
2015-08-23 17:25
190 查看
noip2011C-4-1(子矩阵)输入一个n1*m1的矩阵a,和n2*m2的矩阵b,问a中是否存在子矩阵和b相等。若存在,输出所有子矩阵左上角的坐标;若不存在输出“there is no answer”。
样例输入:
3 3
1 2 3
4 5 6
7 8 9
2 2
5 6
8 9
样例输出:
2 2
样例输入:
3 3
1 2 3
4 5 6
7 8 9
2 2
5 6
8 9
样例输出:
2 2
const SIZE=50; var n1,m1,n2,m2,i,j,k1,k2:integer; a,b:array[1..SIZE,1..SIZE] of integer; good,haveAns:boolean; begin assign(input,'noip2011C_4_1.txt'); reset(input); readln(n1,m1); for i:=1 to n1 do begin for j:=1 to m1 do begin read(a[i][j]); end; end; readln(n2,m2); for i:=1 to n2 do begin for j:=1 to m2 do begin read(b[i][j]); end; end; haveAns:=false; for i:=1 to n1-n2+1 do begin for j:=1 to m1-m2+1 do begin good:=true; for k1:=1 to n2 do begin for k2:=1 to m2 do begin if a[i+k1-1][j+k2-1]<>b[k1][k2] then good:=false; end; end; if good then begin writeln(i,' ',j); haveAns:=true; end; end; end; if not haveAns then writeln('There is no answer'); close(input); end.
相关文章推荐
- 将iPhone投影到Mac上
- 2044 一只小蜜蜂...【递推】
- JAVA BigDecimal 小数点处理
- 大龄屌丝自学笔记--Java零基础到菜鸟--009
- pptv首页导航效果
- XCODE常用的插件
- noip2010初赛-哥德巴赫猜想
- Arrays
- 例题9-8 颜色的长度 UVa1625
- 相亲会成家长会
- Android基础UI之TextView实现跑马灯效果
- HTML5时钟代码
- IntelliJ IDEA 12使用教程
- Android带CheckBox的ListView,全选,CheckBox和ListView事件分离
- 【Nutch】DbUpdaterJob
- 5中服务器网络编程模型讲解
- noip2009初赛-国王放置
- linux命令 - 磁盘分区命令 fdisk 和 parted
- CocoaPods
- 解决Eclipse10配置Pydev不成功的问题