Created
March 23, 2017 18:24
-
-
Save KhaledElshamy/a8e63c786d1bbe130b12087b2cfe6600 to your computer and use it in GitHub Desktop.
B. Meeting- Codeforces Solution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// working.cpp by Bill Weinman <http://bw.org/> | |
#include <bits/stdc++.h> | |
using namespace std; | |
int dx[10001],dy[1001],r[1001],n; | |
int check(int x,int y) | |
{ | |
for(int i=0;i<n;i++) | |
if(((x-dx[i])*(x-dx[i]))+((y-dy[i])*(y-dy[i]))<=r[i]*r[i]) | |
return 0; | |
return 1; | |
} | |
int main() | |
{ | |
int x1,y1,x2,y2,count=0; | |
cin>>x1>>y1>>x2>>y2; | |
cin>>n; | |
for(int i=0;i<n;i++) | |
cin>>dx[i]>>dy[i]>>r[i]; | |
int xmax=max(x1,x2),xmin=min(x1,x2); | |
int ymax=max(y1,y2),ymin=min(y1,y2); | |
for(int i=xmin;i<=xmax;i++) | |
for(int j=ymin;j<=ymax;j++) | |
if(i==xmin||i==xmax||j==ymin||j==ymax) | |
if (check(i,j)) | |
count++; | |
cout<<count<<endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment