이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 (b.first - a.first) * (c.second - a.second) - (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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |