2017年11月01日普及组 I Liked Matrix!
生活随笔
收集整理的這篇文章主要介紹了
2017年11月01日普及组 I Liked Matrix!
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Description
給定一個 n ? m 的矩陣 A,對其進行 q 次詢問:以 (x1,y1) 為左上角,(x2,y2) 為右下角的子矩
陣中,所有元素的最大值。
Input
第一行包含三個整數 n,m 和 q。
之后 n 行每行包含 m 個整數 Aij 。
之后 q 行每行包含四個整數 x1,y1,x2 和 y2。
Output
共 q 行包含一個整數 ans,表示子矩陣中所有元素的最大值。
Sample Input
3 3 2
1 2 3
1 2 3
2 3 1
1 1 2 2
2 2 3 3
Sample Output
2
3
Hint
對于 100% 的數據:n,m,q ≤ 100
分析
直接暴力
程序:
var n,m,q,i,j,ans,x1,x2,y1,y2,k:longint; a:array[0..200,0..200]of longint; beginassign(input,'past.in');reset(input);assign(output,'past.out');rewrite(output);readln(n,m,q);for i:=1 to n dobeginfor j:=1 to m doread(a[i,j]);readln;end;for k:=1 to q dobeginreadln(x1,y1,x2,y2);ans:=0;for i:=x1 to x2 dofor j:=y1 to y2 doif a[i,j]>ans then ans:=a[i,j];writeln(ans);end;close(input);close(output); end.轉載于:https://www.cnblogs.com/YYC-0304/p/9500029.html
總結
以上是生活随笔為你收集整理的2017年11月01日普及组 I Liked Matrix!的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 2017年11月01日普及组 I Got
- 下一篇: 201711月04日普及组 Array