Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
where is my fault?#include <iostream> #include <algorithm> #include <memory.h> using namespace std; typedef struct { short x; short y; }RE; int m,n; int PA[21][21], PB[21][21]; int N; RE res[400]; bool cmp(const RE & a, const RE & b) { if (a.x != b.x) return a.x < b.x; return a.y < b.y; } void Go() { int i,j,k,f; for ( i=1; i<=m; i++) { for ( j=1; j<=n; j++) { f = 1; for ( k=1; k<=n; k++) { if (PB[i][k] > PB[i][j]) { f = 0; break; } } if (f) { for ( k=1; k<=n; k++) { if (PA[k][j] > PA[i][j]) { f = 0; break; } } } if (f) { res[N].x = i; res[N++].y = j; } } } } int main() { int i, j; while (cin>>m>>n && m && n) { for ( i=1; i<=m; i++) for ( j=1; j<=n; j++) cin>>PA[i][j]; for ( i=1; i<=m; i++) for ( j=1; j<=n; j++) cin>>PB[i][j]; N = 0; memset(res, 0, sizeof(res)); Go(); sort(res, res+N, cmp); cout<<N<<endl; for ( i=0; i<N; i++) cout<<res[i].x<<" "<<res[i].y<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator