QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#137458#2350. Integer CowRd_rainydays#Compile Error//C++202.8kb2023-08-10 12:55:222023-08-10 12:55:25

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-10 12:55:25]
  • 评测
  • [2023-08-10 12:55:22]
  • 提交

answer

#include <bits/stdc++.h>

#define sqr(x) ((x) * (x))
using ll = __int128;
struct Point {
  double x, y;
  Point(double x = 0, double y = 0) : x(x), y(y) { }
};
Point operator + (const Point& a, const Point& b) {
  return Point(a.x + b.x, a.y + b.y);
}
Point operator - (const Point& a, const Point& b) {
  return Point(a.x - b.x, a.y - b.y);
}
double dist(const Point& a, const Point& b) {
  return sqrt(sqr(a.x - b.x) + sqr(a.y - b.y));
}
ll SQRT(ll x) {
  // double t = sqrt(x);
  // if (fabs(t - ceil(t)) < 1e-6) return (ll)ceil(t);
  // if (fabs(t - floor(t)) < 1e-6) return (ll)floor(t);
  // return (ll)floor(t);

  ll lb = 0, ub = 1e18, ans = 0;
  while (lb <= ub) {
    ll mid = (lb + ub) / 2;
    if (mid * mid <= x) ans = mid, ub = mid - 1;
    else lb = mid + 1;
  }

  return ans;
}

ll read() {
  long long x;
  scanf("%lld", &x);
  return x;
}

 
void solve() {
  ll cx = read(), cy = read(), r = read(), px = read(), py = read();

  Point c, p;
  c.x = cx, c.y = cy;
  p.x = px, p.y = py;

  if (sqr(cx - px) + sqr(cy - py) <= sqr(r)) {
    printf("0\n%lld %lld\n", (long long)px, (long long)py);
    return;
  }

  Point d = p - c;
  double ld = dist(p, c);
  // assert(ld > 1e-6);
  d.x /= ld, d.y /= ld;
  d.x *= r, d.y *= r;
  Point o = d + c;
  ll r2 = sqr(r);

  std::pair<ll, std::pair<ll, ll>> ans(ll(1e30), {-1e9 -1, -1e9-1});
  for (int i = -30; i <= 30; i++)
    for (int j = -30; j <= 30; j++) {
      ll ox = (ll)o.x + i, oy = (ll)o.y + j;
      if (sqr(ox - cx) + sqr(oy - cy) > sqr(r)) continue;
      ans = std::min(ans, decltype(ans)(sqr(ox - px) + sqr(oy - py), {ox, oy}));
    }
	}
  
  for (int i = -30; i <= 30; i++) {
    ll ox = (ll)o.x + i;
    if(r2 - sqr(ox-cx)<0) continue;
    ll yyy = SQRT(r2 - sqr(ox-cx));
    ll oy = (ll)o.y - yyy;
    if(sqr(ox - cx) + sqr(oy - cy) <= sqr(r))
      ans = std::min(ans, decltype(ans)(sqr(ox - px) + sqr(oy - py), {ox, oy}));
    oy = (ll)o.y + yyy;
    if (sqr(ox - cx) + sqr(oy - cy) <= sqr(r))
      ans = std::min(ans, decltype(ans)(sqr(ox - px) + sqr(oy - py), {ox, oy}));
  }
  for (int j = -30; j <= 30; j++) {
    ll oy = (ll)o.y + j;
    if(r2 - sqr(oy-cy)<0) continue;
    ll xxx = SQRT(r2 - sqr(oy-cy));

    ll ox = (ll)o.x - xxx;
    if (sqr(ox - cx) + sqr(oy - cy) <= sqr(r))
      ans = std::min(ans, decltype(ans)(sqr(ox - px) + sqr(oy - py), {ox, oy}));
    ox = (ll)o.x + xxx;
    if (sqr(ox - cx) + sqr(oy - cy) <= sqr(r))
      ans = std::min(ans, decltype(ans)(sqr(ox - px) + sqr(oy - py), {ox, oy}));
  }
  
  auto [ox, oy] = ans.second;
  assert(ox != -(int)1e9-1 && oy != -(int)1e9-1);
  printf("1\n%lld %lld %lld %lld\n", (long long)px, (long long)py, (long long)ox, (long long)oy);
}

signed main() {
  int T;
  scanf("%d", &T);
  while (T--) solve();
  return 0;
}
/*
1
0 0 500000000 1000000000 0
*/

詳細信息

answer.code:70:3: error: expected unqualified-id before ‘for’
   70 |   for (int i = -30; i <= 30; i++) {
      |   ^~~
answer.code:70:21: error: ‘i’ does not name a type
   70 |   for (int i = -30; i <= 30; i++) {
      |                     ^
answer.code:70:30: error: ‘i’ does not name a type
   70 |   for (int i = -30; i <= 30; i++) {
      |                              ^
answer.code:81:3: error: expected unqualified-id before ‘for’
   81 |   for (int j = -30; j <= 30; j++) {
      |   ^~~
answer.code:81:21: error: ‘j’ does not name a type
   81 |   for (int j = -30; j <= 30; j++) {
      |                     ^
answer.code:81:30: error: ‘j’ does not name a type
   81 |   for (int j = -30; j <= 30; j++) {
      |                              ^
answer.code:94:19: error: ‘ans’ was not declared in this scope; did you mean ‘abs’?
   94 |   auto [ox, oy] = ans.second;
      |                   ^~~
      |                   abs
In file included from /usr/include/c++/11/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:33,
                 from answer.code:1:
answer.code:95:3: error: expected unqualified-id before ‘static_cast’
   95 |   assert(ox != -(int)1e9-1 && oy != -(int)1e9-1);
      |   ^~~~~~
answer.code:95:3: error: expected ‘)’ before ‘static_cast’
answer.code:96:9: error: expected constructor, destructor, or type conversion before ‘(’ token
   96 |   printf("1\n%lld %lld %lld %lld\n", (long long)px, (long long)py, (long long)ox, (long long)oy);
      |         ^
answer.code:97:1: error: expected declaration before ‘}’ token
   97 | }
      | ^
answer.code: In function ‘ll read()’:
answer.code:36:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   36 |   scanf("%lld", &x);
      |   ~~~~~^~~~~~~~~~~~
answer.code: In function ‘int main()’:
answer.code:101:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  101 |   scanf("%d", &T);
      |   ~~~~~^~~~~~~~~~