제출 #265484

#제출 시각아이디문제언어결과실행 시간메모리
265484DS007Circle selection (APIO18_circle_selection)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define int long long struct circle { int x, y, r, i; bool operator < (circle c) { if (r == c.r) return i < c.i; return r > c.r; } }; const int N = 3e5; circle c[N]; bool done[N]; int n, ans[N]; int solveTestCase() { cin >> n; for (int i = 0; i < n; i++) cin >> c[i].x >> c[i].y >> c[i].r, c[i].i = i + 1; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (c[j] < c[j + 1]) { circle temp = c[j].r; c[j].r + c[j + 1].r; c[j + 1].r = temp; } } } for (int i = 0; i < n; i++) { if (done[i]) continue; ans[c[i].i] = c[i].i; for (int j = i + 1; j < n; j++) { int dist = (c[i].y - c[j].y) * (c[i].y - c[j].y) + (c[i].x - c[j].x) * (c[i].x - c[j].x); if (dist <= (c[i].r + c[j].r) * (c[i].r + c[j].r)) done[j] = true, ans[c[j].i] = c[i].i; } } for (int i = 1; i <= n; i++) cout << ans[i] << " "; } signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int t = 1; //cin >> t; while (t--) solveTestCase(); }

컴파일 시 표준 에러 (stderr) 메시지

circle_selection.cpp: In function 'long long int solveTestCase()':
circle_selection.cpp:28:36: error: conversion from 'long long int' to non-scalar type 'circle' requested
   28 |                 circle temp = c[j].r;
      |                               ~~~~~^
circle_selection.cpp:29:24: warning: statement has no effect [-Wunused-value]
   29 |                 c[j].r + c[j + 1].r;
      |                 ~~~~~~~^~~~~~~~~~~~
circle_selection.cpp:30:30: error: cannot convert 'circle' to 'long long int' in assignment
   30 |                 c[j + 1].r = temp;
      |                              ^~~~
      |                              |
      |                              circle
circle_selection.cpp:49:1: warning: no return statement in function returning non-void [-Wreturn-type]
   49 | }
      | ^