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 |
谁有数据让它WA哇#include<cstdio> #include<cstring> #define size 1005 int n, m, t, p, q; char sky[size][size], con[55][55]; __int64 sums[size][size], sumc[105][55]; int ans; int main( void ) { int caseNum = 0; int r, c, i, j; __int64 tmp1, tmp2; bool done, flag; while ( scanf( "%d%d%d%d%d", &n, &m, &t, &p, &q ), n ){ for ( r = 0; r < n; r++ ){ scanf( "%s", sky[r] ); for ( c = 0, sums[r][0] = 0; c+q <= m && c < q; c++ ){ tmp1 = sky[r][c] == '*' ? 1 : 0; sums[r][0] = (sums[r][0]<<1)+tmp1; } for ( c = 1; c+q <= m; c++ ){ tmp1 = sky[r][c-1] == '*' ? 1 : 0; tmp2 = sky[r][c+q-1] == '*' ? 1 : 0; sums[r][c] = ((sums[r][c-1] - (tmp1 << (q-1))) << 1)+tmp2; } } for ( i = 0; i < t; i++ ){ for ( r = 0; r < p; r++ ){ scanf( "%s", con[r] ); for ( c = 0, sumc[i][r] = 0; c < q; c++ ){ sumc[i][r] = (sumc[i][r]<<1)+(con[r][c] == '*' ? 1 : 0); } } } for ( ans = 0, i = 0; i < t; i++ ){ for ( done = false, r = 0; r+p <= n && !done; r++ ){ for ( c = 0; c+q <= m && !done; c++ ){ for ( flag = true, j = 0; j < p && flag; j++ ) if ( sums[r+j][c] != sumc[i][j] ) flag = false; if ( flag ) ans++, done = true; } } } printf( "Case %d: %d\n", ++caseNum, ans ); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator