|
|
back to boardPlease help 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 |
|
|