Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cmath>
- #include <cstdio>
- #include <vector>
- #include <iostream>
- #include <algorithm>
- #include <map>
- using namespace std;
- map<long long,bool> v;
- struct date
- {
- int month,day,year,hour,minute;
- bool operator < (date b) /// a<b
- {
- date a = *this;
- if(a.year < b.year)
- return true;
- else if(a.year > b.year)
- return false;
- else if(a.month < b.month)
- return true;
- else if(a.month > b.month)
- return false;
- else if(a.day < b.day)
- return true;
- else if(a.day > b.day)
- return false;
- else if(a.hour < b.hour)
- return true;
- else if(a.hour > b.hour)
- return false;
- else if(a.minute < b.minute)
- return true;
- else if(a.minute > b.minute)
- return false;
- else
- return false;
- }
- bool operator > (date b)
- {
- return !(*this<b);
- }
- };
- struct data
- {
- date d;
- long double lat,lon;
- long long phone;
- bool operator < (data b)
- {
- return this->d < b.d;
- }
- };
- string read_str()
- {
- char c = getchar();
- string ans;
- while(c!=',' && c!='\n')
- {
- ans += c;
- c = getchar();
- }
- return ans;
- }
- long double read_ldbl()
- {
- long double ans;
- cin>>ans;
- return ans;
- }
- long long read_longlong()
- {
- long long ans;
- cin>>ans;
- return ans;
- }
- date read_date()
- {
- date neo;
- char bs;
- cin>>neo.month>>bs>>neo.day>>bs>>neo.year>>neo.hour>>bs>>neo.minute;
- return neo;
- }
- long double LAT,LON;
- vector<data> input;
- int main() {
- cin>>LAT;
- LAT = LAT*(M_PI/180.0L);
- getchar();
- cin>>LON;
- LON = LON*(M_PI/180.0L);
- long double r;
- cin>>r;
- string s;
- vector<int> order;
- getchar();
- for(int i=0;i<4;++i)
- {
- s = read_str();
- if(s == "Date&Time")
- order.push_back(0);
- if(s == "Latitude")
- order.push_back(1);
- if(s == "Longitude")
- order.push_back(2);
- if(s == "PhoneNumber")
- order.push_back(3);
- //cout<<order[i]<<" ";
- }
- //cout<<"\n";
- int tmp;
- char bs;
- data neo;
- while(!cin.eof())
- {
- for(int i=0;i<order.size();++i)
- {
- switch(order[i])
- {
- case 0:
- neo.d = read_date();
- break;
- case 1:
- neo.lat = read_ldbl();
- break;
- case 2:
- neo.lon = read_ldbl();
- break;
- case 3:
- neo.phone = read_longlong();
- break;
- }
- getchar();
- if(cin.eof())
- goto skip;
- }
- neo.lat = neo.lat*(M_PI/180.0L);
- neo.lon = neo.lon*(M_PI/180.0L);
- input.push_back(neo);
- }
- skip:
- sort(input.begin() , input.end());
- bool first = true;
- vector<long long> PHONE;
- for(int i=input.size()-1;i>=0;--i)
- {
- if(!v[input[i].phone])
- {
- v[input[i].phone] = true;
- long double d = 2.0L * 6378.137L * asin (sqrt (sin((LAT - input[i].lat)/2.0L)*sin((LAT - input[i].lat)/2.0L) + cos(LAT) * cos(input[i].lat) * sin((LON - input[i].lon)/2.0L)*sin((LON - input[i].lon)/2.0L)));
- if(d>r)
- continue;
- PHONE.push_back(input[i].phone);
- }
- }
- sort(PHONE.begin(),PHONE.end());
- for(int i=0;i<PHONE.size();++i)
- cout<<PHONE[i]<<(i==PHONE.size()-1?"":",");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement