This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define int long long
vector <pair <int, int> > pol;
int n;
bool crossproduct(pair <int, int> a, pair <int, int> b, pair <int, int> c)
{
return (long double) (b.first - a.first) * (c.second - a.second) >= (long double)(b.second - a.second) * (c.first - a.first) >= 0;
}
int check(pair <int, int> a, int l, int r)
{
int al = l, ar = r + 1;
while(ar - al > 1)
{
int midd = (ar + al) / 2;
if(crossproduct(a, pol[midd], pol[(midd + 1) % n]) == crossproduct(a, pol[l], pol[(l + 1) % n]))
{
al = midd;
}
else
{
ar = midd;
}
}
if(crossproduct(a, pol[l], pol[(l + 1) % n]))
{
return al - l + 1;
}
else
{
return (r - l + 1) - (al - l + 1);
}
}
bool solve(int x, int y)
{
bool a = crossproduct({x, y}, pol[0], pol[1]);
bool b = crossproduct({x, y}, pol[n / 2], pol[n / 2 + 1]);
if(a == b)
{
return a;
}
return check({x, y}, 0, n / 2 - 1) + check({x, y}, n / 2, n - 1) > n / 2;
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t;
cin >> t >> n;
pol.resize(n);
for(int i = 0; i < n; i++)
{
cin >> pol[i].first >> pol[i].second;
}
int q;
cin >> q;
int preans = 0;
while(q--)
{
int x, y;
cin >> x >> y;
x ^= t * preans * preans * preans;
y ^= t * preans * preans * preans;
int ans = solve(x, y);
preans += ans;
if(ans)
{
cout << "DA\n";
}
else
{
cout << "NE\n";
}
}
return 0;
}
Compilation message (stderr)
zvijezda.cpp: In function 'bool crossproduct(std::pair<long long int, long long int>, std::pair<long long int, long long int>, std::pair<long long int, long long int>)':
zvijezda.cpp:9:127: warning: comparison of constant '0' with boolean expression is always true [-Wbool-compare]
return (long double) (b.first - a.first) * (c.second - a.second) >= (long double)(b.second - a.second) * (c.first - a.first) >= 0;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
zvijezda.cpp:9:67: warning: comparisons like 'X<=Y<=Z' do not have their mathematical meaning [-Wparentheses]
return (long double) (b.first - a.first) * (c.second - a.second) >= (long double)(b.second - a.second) * (c.first - a.first) >= 0;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |