QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#859194 | #9668. Isoball: 2D Version | shiyahahaya# | Compile Error | / | / | C++20 | 4.3kb | 2025-01-17 16:18:00 | 2025-01-17 16:18:01 |
Judging History
answer
#include <iostream>
#include <math.h>
#include <numbers>
using namespace std;
double PI = std::numbers::pi;
double xo, yo, r, vx, vy, x1, y1, x2, y2;
struct place
{
double px;
double py;
};
double trans(place O, place A)
{
//cout << "A: " << A.px << " " << A.py << endl;
double tana = (A.py - O.py) / (A.px - O.px);
if (A.px >= 0 && A.py >= 0)
{
return atan(tana);
}
else if (A.px < 0 && A.py <= 0)
{
return PI + atan(tana);
}
else if (A.px <= 0 && A.py >= 0)
{
return PI + atan(tana);
}
else if (A.px >= 0 && A.py <= 0)
{
return 2 * PI + atan(tana);
}
return atan(tana);
}
int main()
{
long int n;
cin >> n;
while (n--)
{
cin >> xo >> yo >> r >> vx >> vy >> x1 >> y1 >> x2 >> y2;
swap(y1, y2);
// cout << x1 << " " << y1 << " " << x2 << " " << y2 << endl;
if (abs(x1 - x2) < 2 * r || abs(y1 - y2) < 2 * r)
{
cout << "NO" << endl;
continue;
}
double L = pow(vx * vx + vy * vy, 0.5);
place leftp = {xo, yo};
place rightp = {xo + 3000000 * vx / L, yo + 3000000 * vy / L};
double t = trans(leftp, rightp) / PI;/*
cout << x1 + r << " ... " << y1 - r << endl;
cout << x1 + r << " ... " << y2 + r << endl;
cout << x2 - r << " ... " << y1 - r << endl;
cout << x2 - r << " ... " << y2 + r << endl;*/
double a = trans(leftp, {x1 + r, y1 - r}) / PI;
double b = trans(leftp, {x1 + r, y2 + r}) / PI;
double c = trans(leftp, {x2 - r, y1 - r}) / PI;
double d = trans(leftp, {x2 - r, y2 + r}) / PI;
/*
cout << t << " * PI" << endl;
cout << a << " * PI" << endl;
cout << b << " * PI" << endl;
cout << c << " * PI" << endl;
cout << d << " * PI" << endl;
*/
if (xo < x1 + r)
{
if (yo > y1 - r)
{
//cout << 1 << endl;
if ((t >= 0 && t < b) || (t <= 2 && t > c))
{
cout << "NO" << endl;
continue;
}
}
else if (yo < y2 + r)
{
//cout << 2 << endl;
if ((t > a && t <= 2) || (t < d && t >= 0))
{
cout << "NO" << endl;
continue;
}
}
else
{
//cout << 3 << endl;
if (t > a && t < b)
{
cout << "NO" << endl;
continue;
}
}
}
else if (xo > x2 - r)
{
if (yo > y1 - r)
{
//cout << 4 << endl;
if ((t > d && t <= 2) || (t < a && t >= 0))
{
cout << "NO" << endl;
continue;
}
}
else if (yo < y2 + r)
{
//cout << 5 << endl;
if ((t > b && t <= 2) || (t < c && t >= 0))
{
cout << "NO" << endl;
continue;
}
}
else
{
//cout << 6 << endl;
if ((t > d && t <= 2) || (t < c && t >= 0))
{
cout << "NO" << endl;
continue;
}
}
}
else
{
if (yo > y1 - r)
{
//cout << 7 << endl;
if ((t > c && t <= 2) || (t < a && t >= 0))
{
cout << "NO" << endl;
continue;
}
}
else if (yo < y2 + r)
{
//cout << 8 << endl;
if ((t > b && t <= 2) || (t < d && t >= 0))
{
cout << "NO" << endl;
continue;
}
}/*
else
{
//cout << 9 << endl;
}*/
}
cout << "YES" << endl;
}
return 0;
}
Details
answer.code:9:31: error: ‘double y1’ redeclared as different kind of entity 9 | double xo, yo, r, vx, vy, x1, y1, x2, y2; | ^~ In file included from /usr/include/features.h:502, from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:680, from /usr/include/c++/14/bits/requires_hosted.h:31, from /usr/include/c++/14/iostream:38, from answer.code:1: /usr/include/x86_64-linux-gnu/bits/mathcalls.h:224:1: note: previous declaration ‘double y1(double)’ 224 | __MATHCALL (y1,, (_Mdouble_)); | ^~~~~~~~~~ answer.code: In function ‘int main()’: answer.code:46:48: error: no match for ‘operator>>’ (operand types are ‘std::basic_istream<char>::__istream_type’ {aka ‘std::basic_istream<char>’} and ‘double(double) noexcept’) 46 | cin >> xo >> yo >> r >> vx >> vy >> x1 >> y1 >> x2 >> y2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^~ ~~ | | | | | double(double) noexcept | std::basic_istream<char>::__istream_type {aka std::basic_istream<char>} In file included from /usr/include/c++/14/iostream:42: /usr/include/c++/14/istream:170:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match) 170 | operator>>(bool& __n) | ^~~~~~~~ /usr/include/c++/14/istream:170:7: note: conversion of argument 1 would be ill-formed: answer.code:46:51: error: cannot bind non-const lvalue reference of type ‘bool&’ to a value of type ‘double (*)(double) noexcept’ 46 | cin >> xo >> yo >> r >> vx >> vy >> x1 >> y1 >> x2 >> y2; | ^~ /usr/include/c++/14/istream:174:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]’ (near match) 174 | operator>>(short& __n); | ^~~~~~~~ /usr/include/c++/14/istream:174:7: note: conversion of argument 1 would be ill-formed: answer.code:46:51: error: invalid conversion from ‘double (*)(double) noexcept’ to ‘short int’ [-fpermissive] 46 | cin >> xo >> yo >> r >> vx >> vy >> x1 >> y1 >> x2 >> y2; | ^~ | | | double (*)(double) noexcept answer.code:46:51: error: cannot bind rvalue ‘(short int)y1’ to ‘short int&’ /usr/include/c++/14/istream:177:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match) 177 | operator>>(unsigned short& __n) | ^~~~~~~~ /usr/include/c++/14/istream:177:7: note: conversion of argument 1 would be ill-formed: answer.code:46:51: error: invalid conversion from ‘double (*)(double) noexcept’ to ‘short unsigned int’ [-fpermissive] 46 | cin >> xo >> yo >> r >> vx >> vy >> x1 >> y1 >> x2 >> y2; | ^~ | | | double (*)(double) noexcept answer.code:46:51: error: cannot bind rvalue ‘(short unsigned int)y1’ to ‘short unsigned int&’ /usr/include/c++/14/istream:181:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]’ (near match) 181 | operator>>(int& __n); | ^~~~~~~~ /usr/include/c++/14/istream:181:7: note: conversion of argument 1 would be ill-formed: answer.code:46:51: error: invalid conversion from ‘double (*)(double) noexcept’ to ‘int’ [-fpermissive] 46 | cin >> xo >> yo >> r >> vx >> vy >> x1 >> y1 >> x2 >> y2; | ^~ | | | double (*)(double) noexcept answer.code:46:51: error: cannot bind rvalue ‘(int)y1’ to ‘int&’ /usr/include/c++/14/istream:184:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match) 184 | operator>>(unsigned int& __n) | ^~~~~~~~ /usr/inc...