ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1168. Radio Stations

Please help
Posted by RAVEman 1 Jul 2007 04:17
Where am i wrong? It should be obvious :) because it is WA2

#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <iostream>
#include <fstream>
#include <iterator>
#include <math.h>
#include <cstdio>
#include <cstdlib>
#include <sstream>

using namespace std;
const double eps=1e-6;

struct R{
    int x;
    int y;
    double r;
};

R r[1111];
int a[55][55];
bool s[55][55];
int n,m,k,x,y;

int main(){
    cin>>n>>m>>k;
    for(int i=0;i<m;i++)
        for(int j=0;j<n;j++)
            cin>>a[i][j];
    for(int i=0;i<k;i++){
        cin>>r[i].x>>r[i].y>>r[i].r;
        r[i].x--;r[i].y--;
        s[r[i].x][r[i].y]=true;
    }
    long res=0;
    for(int i=0;i<m;i++)
        for(int j=0;j<n;j++)
            if(!s[i][j]){
                bool possible=true;
                double d;
                int mina=a[i][j];
                int maxa=32000;
                int _mna,_mxa;
                for(int q=0;q<k;q++){
                    d=r[q].r*r[q].r-(i-r[q].x)*(i-r[q].x)-(j-r[q].y)*(j-r[q].y);
                    if(d<-eps) {possible=false;break;}
                    d=floor(sqrt(d+eps))+eps;
                    _mna=d;_mna=a[r[q].x][r[q].y]-_mna;
                    _mxa=d;_mxa=a[r[q].x][r[q].y]+_mxa;
                    if(mina<_mna) mina=_mna;
                    if(maxa>_mxa) maxa=_mxa;
                    if(mina>maxa) {possible=false;break;}
                }
                if(possible)
                    res+=(maxa-mina+1);
            }

    cout<<res<<endl;
    return 0;
}

Edited by author 01.07.2007 04:19