# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
4243 |
2013-09-06T06:58:25 Z |
sjw0687 |
Jogging (kriii1_J) |
C++ |
|
8 ms |
2132 KB |
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
using namespace std;
const int INF = INT_MAX / 2;
typedef pair<int, double> pid;
struct Star {
int x,y;
bool operator < (const Star rhs) const {
return x != rhs.x ? x < rhs.x : y > rhs.y;
}
};
int n;
int m;
Star stars[10001];
int xRest[10000];
double answer[10000];
int minX[10000];
stack< pid > s;
double calXBoundary(Star& s1, Star& s2)
{
double a = (double) (s2.y - s1.y) / (s2.x - s1.x);
double b = s1.y - a * s1.x;
return -b/a;
}
int main(void)
{
cin >> n >> m;
for(int i=0; i<n; i++) {
cin >> stars[i].x >> stars[i].y;
}
stars[n].x = 100000001; stars[n].y = 0;
for(int i=0; i<m; i++)
cin >> xRest[i];
sort(stars, stars+n);
int iStar = n;
s.push( pid(n, -INF) );
for(int i=m-1; i>=0; i--) {
int& x = xRest[i];
while(x <= s.top().second)
s.pop();
while(iStar > 0 && x < stars[iStar-1].x) {
Star& newStar = stars[iStar-1];
while(!s.empty() && newStar.y >= stars[s.top().first].y) {
s.pop();
}
if( !s.empty() )
s.push( pid(iStar-1, calXBoundary(newStar, stars[s.top().first])) );
else
s.push( pid(iStar-1, -INF) );
while(x <= s.top().second)
s.pop();
iStar--;
}
answer[i] = atan2( (double)stars[s.top().first].y, (stars[s.top().first].x - x) );
}
for(int i=0; i<m; i++) {
cout.precision(7); cout.setf(ios::fixed);
cout << answer[i] << endl;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
8 ms |
2132 KB |
SIGSEGV Segmentation fault |
2 |
Halted |
0 ms |
0 KB |
- |