Skip to content
Narrow screen resolution Wide screen resolution Auto adjust screen size Increase font size Decrease font size Default font size default color grey color
         
 | 
VNOI - Olympic tin học Việt Nam

Điểm tin VOJ

Số thành viên:6040
Số bài tập:1001
Số bài nộp:722923
Bài nộp hôm nay:0

Top 10 thành viên xuất sắc

HạngThành viênĐiểm
1mr_invincible587.9
2white_cobra418.6
3hieult403.4
4phaleq384.0
5vodanh9x368.2
6con_nha_ngheo352.0
7flash_mt350.2
8darksabers349.8
9yenthanh132345.3
10rockman9x_94343.1
[VOJ] Mã nguồn #223 - C11NHL
Ngày: 18-08-2012
Cập nhật: 18-08-2012
Người gửi: yenthanh132
Ngôn ngữ: C++
Xem: 422

Điểm: 3.0/5 (6 Phiếu)


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cstring>
#include <string>
#include <cmath>
#include <ctime>
#include <utility>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <sstream>
#define FOR(a,b,c) for (int a=b,_c=c;a<=_c;a++)
#define FORD(a,b,c) for (int a=b;a>=c;a--)
#define REP(i,a) for(int i=0,_a=(a); i<_a; ++i)
#define REPD(i,a) for(int i=(a)-1; i>=0; --i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) int(a.size())
#define reset(a,b) memset(a,b,sizeof(a))
#define oo 1000000007
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long double, pii> pdii;
 
const int maxn=507;
const long double lim = 1e-9;
 
int m,n,d;
long double s[maxn][maxn];
bool mark[maxn][maxn];
vector<pdii> list;
vector<pii> res;
 
bool mycmp(const pdii &a, const pdii &b){
    if(fabs(a.fi-b.fi)<lim) return(a.se<b.se);
    if(a.fi>b.fi) return 1; else return 0;
}
 
//#include <conio.h>
int main(){
    int v,x0,y0,x1,y1;
    pdii t;
    //freopen("23.in","r",stdin);
    //freopen("23_2.out","w",stdout);
 
    scanf("%d%d%d",&m,&n,&d);
 
    FOR(i,1,m){
        FOR(j,1,n){
            scanf("%d",&v);
            s[i][j]=s[i-1][j]+s[i][j-1]-s[i-1][j-1]+log(v);
        }
        scanf("\n");
    }
 
    FOR(i,1,m-d+1) FOR(j,1,n-d+1){
        t.fi=s[i+d-1][j+d-1]-s[i-1][j+d-1]-s[i+d-1][j-1]+s[i-1][j-1];
        t.se=pii(i,j);
        list.pb(t);
    }
    sort(list.begin(),list.end(),mycmp);
    reset(mark,0);
 
    REP(i,sz(list)){
        x0=list[i].se.fi; y0=list[i].se.se;
        x1=x0+d-1; y1=y0+d-1;
        if(mark[x0][y0] || mark[x1][y0] || mark[x0][y1] || mark[x1][y1]) continue;
        res.pb(list[i].se);
        FOR(x,x0,x1) FOR(y,y0,y1) mark[x][y]=1;
    }
 
    printf("%d\n",sz(res));
    REP(i,sz(res)) printf("%d %d\n",res[i].fi,res[i].se);
 
    //cout<<1.0*clock()/CLOCKS_PER_SEC<<endl;
    //getch();
    return 0;
}