Task: | Taxing |
Sender: | guq2 |
Submission time: | 2016-09-17 15:58:57 +0300 |
Language: | C++ |
Status: | READY |
Result: | WRONG ANSWER |
test | verdict | time | |
---|---|---|---|
#1 | WRONG ANSWER | 0.06 s | details |
#2 | WRONG ANSWER | 0.06 s | details |
#3 | WRONG ANSWER | 0.06 s | details |
#4 | WRONG ANSWER | 0.05 s | details |
#5 | WRONG ANSWER | 0.05 s | details |
Code
#include <iostream> #include <cstdio> #include <cmath> #include <algorithm> #include <vector> #include <utility> using namespace std; vector<pair<int, int> > point; double Angle(int x1, int y1, int x2, int y2) { //acos return radian,we should transform it into degree return acos((x1*x2 + y1*y2) / sqrt((x1*x1 + y1*y1)*(x2*x2 + y2*y2)))*180/M_PI; } int judge(int x, int y) { double angle = 0; double tmp; int len=point.size(); for(int i=0; i<len; i++) { if(i==(len-1)) tmp = Angle(point[i].first-x, point[i].second-y, point[0].first-x, point[0].second-y); else tmp = Angle(point[i].first-x, point[i].second-y, point[i+1].first-x, point[i+1].second-y); if(fabs(tmp-180.0)<1e-4) return 0; angle+=tmp; } if(fabs(angle-360.0)<1e-4) return 1; else return -1; } int main() { ios::sync_with_stdio(0); int n, m; int x, y; while(cin>>n) { point.clear(); while(n--) { cin>>x>>y; point.push_back(make_pair(x, y)); } cin>>m; while(m--) { cin>>x>>y; int length = point.size(); int flag=0; for(int i=0; i<length; i++) if(x==point[i].first && y==point[i].second) { cout<<"border"<<endl; flag=1; break; } if(flag==1) continue; int ans = judge(x, y); if(ans==1) cout<<"inside"<<endl; else if(ans==-1) cout<<"outside"<<endl; else cout<<"border"<<endl; } } return 0; }
Test details
Test 1
Verdict: WRONG ANSWER
input |
---|
9 0 10 -2 0 -1 -4 -7 1 ... |
correct output |
---|
inside inside inside outside inside ... |
user output |
---|
outside outside outside outside outside ... |
Test 2
Verdict: WRONG ANSWER
input |
---|
99 13 4 14 8 10 5 9 6 ... |
correct output |
---|
inside border inside outside inside ... |
user output |
---|
outside border outside outside outside ... |
Test 3
Verdict: WRONG ANSWER
input |
---|
99 50 33 28 57 80 28 37 60 ... |
correct output |
---|
outside inside outside inside outside ... |
user output |
---|
outside outside outside outside outside ... |
Test 4
Verdict: WRONG ANSWER
input |
---|
999 87 -3 91 5 77 -7 41 -18 ... |
correct output |
---|
inside outside inside outside outside ... |
user output |
---|
outside outside outside outside outside ... |
Test 5
Verdict: WRONG ANSWER
input |
---|
999 915887 494689 950720 189774 823677 443456 879821 402443 ... |
correct output |
---|
outside outside inside inside inside ... |
user output |
---|
outside outside outside outside outside ... |