답안 #265485

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
265485 2020-08-14T22:08:03 Z DS007 원 고르기 (APIO18_circle_selection) C++14
컴파일 오류
0 ms 0 KB
#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];
                c[j] + c[j + 1];
                c[j + 1] = 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();
}


Compilation message

circle_selection.cpp: In function 'long long int solveTestCase()':
circle_selection.cpp:29:22: error: no match for 'operator+' (operand types are 'circle' and 'circle')
   29 |                 c[j] + c[j + 1];
      |                 ~~~~ ^ ~~~~~~~~
      |                    |          |
      |                    circle     circle
In file included from /usr/include/c++/9/bits/stl_algobase.h:67,
                 from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from circle_selection.cpp:1:
/usr/include/c++/9/bits/stl_iterator.h:423:5: note: candidate: 'template<class _Iterator> std::reverse_iterator<_Iterator> std::operator+(typename std::reverse_iterator<_Iterator>::difference_type, const std::reverse_iterator<_Iterator>&)'
  423 |     operator+(typename reverse_iterator<_Iterator>::difference_type __n,
      |     ^~~~~~~~
/usr/include/c++/9/bits/stl_iterator.h:423:5: note:   template argument deduction/substitution failed:
circle_selection.cpp:29:31: note:   'circle' is not derived from 'const std::reverse_iterator<_Iterator>'
   29 |                 c[j] + c[j + 1];
      |                               ^
In file included from /usr/include/c++/9/bits/stl_algobase.h:67,
                 from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from circle_selection.cpp:1:
/usr/include/c++/9/bits/stl_iterator.h:1219:5: note: candidate: 'template<class _Iterator> std::move_iterator<_IteratorL> std::operator+(typename std::move_iterator<_IteratorL>::difference_type, const std::move_iterator<_IteratorL>&)'
 1219 |     operator+(typename move_iterator<_Iterator>::difference_type __n,
      |     ^~~~~~~~
/usr/include/c++/9/bits/stl_iterator.h:1219:5: note:   template argument deduction/substitution failed:
circle_selection.cpp:29:31: note:   'circle' is not derived from 'const std::move_iterator<_IteratorL>'
   29 |                 c[j] + c[j + 1];
      |                               ^
In file included from /usr/include/c++/9/string:55,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from circle_selection.cpp:1:
/usr/include/c++/9/bits/basic_string.h:6020:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&)'
 6020 |     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/9/bits/basic_string.h:6020:5: note:   template argument deduction/substitution failed:
circle_selection.cpp:29:31: note:   'circle' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>'
   29 |                 c[j] + c[j + 1];
      |                               ^
In file included from /usr/include/c++/9/string:56,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from circle_selection.cpp:1:
/usr/include/c++/9/bits/basic_string.tcc:1158:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(const _CharT*, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&)'
 1158 |     operator+(const _CharT* __lhs,
      |     ^~~~~~~~
/usr/include/c++/9/bits/basic_string.tcc:1158:5: note:   template argument deduction/substitution failed:
circle_selection.cpp:29:31: note:   mismatched types 'const _CharT*' and 'circle'
   29 |                 c[j] + c[j + 1];
      |                               ^
In file included from /usr/include/c++/9/string:56,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from circle_selection.cpp:1:
/usr/include/c++/9/bits/basic_string.tcc:1174:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(_CharT, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&)'
 1174 |     operator+(_CharT __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs)
      |     ^~~~~~~~
/usr/include/c++/9/bits/basic_string.tcc:1174:5: note:   template argument deduction/substitution failed:
circle_selection.cpp:29:31: note:   'circle' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>'
   29 |                 c[j] + c[j + 1];
      |                               ^
In file included from /usr/include/c++/9/string:55,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from circle_selection.cpp:1:
/usr/include/c++/9/bits/basic_string.h:6057:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*)'
 6057 |     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/9/bits/basic_string.h:6057:5: note:   template argument deduction/substitution failed:
circle_selection.cpp:29:31: note:   'circle' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>'
   29 |                 c[j] + c[j + 1];
      |                               ^
In file included from /usr/include/c++/9/string:55,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from circle_selection.cpp:1:
/usr/include/c++/9/bits/basic_string.h:6073:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, _CharT)'
 6073 |     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, _CharT __rhs)
      |     ^~~~~~~~
/usr/include/c++/9/bits/basic_string.h:6073:5: note:   template argument deduction/substitution failed:
circle_selection.cpp:29:31: note:   'circle' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>'
   29 |                 c[j] + c[j + 1];
      |                               ^
In file included from /usr/include/c++/9/string:55,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from circle_selection.cpp:1:
/usr/include/c++/9/bits/basic_string.h:6085:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&)'
 6085 |     operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
      |     ^~~~~~~~
/usr/include/c++/9/bits/basic_string.h:6085:5: note:   template argument deduction/substitution failed:
circle_selection.cpp:29:31: note:   'circle' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>'
   29 |                 c[j] + c[j + 1];
      |                               ^
In file included from /usr/include/c++/9/string:55,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from circle_selection.cpp:1:
/usr/include/c++/9/bits/basic_string.h:6091:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&)'
 6091 |     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/9/bits/basic_string.h:6091:5: note:   template argument deduction/substitution failed:
circle_selection.cpp:29:31: note:   'circle' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>'
   29 |                 c[j] + c[j + 1];
      |                               ^
In file included from /usr/include/c++/9/string:55,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from circle_selection.cpp:1:
/usr/include/c++/9/bits/basic_string.h:6097:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&)'
 6097 |     operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
      |     ^~~~~~~~
/usr/include/c++/9/bits/basic_string.h:6097:5: note:   template argument deduction/substitution failed:
circle_selection.cpp:29:31: note:   'circle' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>'
   29 |                 c[j] + c[j + 1];
      |                               ^
In file included from /usr/include/c++/9/string:55,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from circle_selection.cpp:1:
/usr/include/c++/9/bits/basic_string.h:6109:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(const _CharT*, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&)'
 6109 |     operator+(const _CharT* __lhs,
      |     ^~~~~~~~
/usr/include/c++/9/bits/basic_string.h:6109:5: note:   template argument deduction/substitution failed:
circle_selection.cpp:29:31: note:   mismatched types 'const _CharT*' and 'circle'
   29 |                 c[j] + c[j + 1];
      |                               ^
In file included from /usr/include/c++/9/string:55,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from circle_selection.cpp:1:
/usr/include/c++/9/bits/basic_string.h:6115:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(_CharT, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&)'
 6115 |     operator+(_CharT __lhs,
      |     ^~~~~~~~
/usr/include/c++/9/bits/basic_string.h:6115:5: note:   template argument deduction/substitution failed:
circle_selection.cpp:29:31: note:   'circle' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>'
   29 |                 c[j] + c[j + 1];
      |                               ^
In file included from /usr/include/c++/9/string:55,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from circle_selection.cpp:1:
/usr/include/c++/9/bits/basic_string.h:6121:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&, const _CharT*)'
 6121 |     operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
      |     ^~~~~~~~
/usr/include/c++/9/bits/basic_string.h:6121:5: note:   template argument deduction/substitution failed:
circle_selection.cpp:29:31: note:   'circle' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>'
   29 |                 c[j] + c[j + 1];
      |                               ^
In file included from /usr/include/c++/9/string:55,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from circle_selection.cpp:1:
/usr/include/c++/9/bits/basic_string.h:6127:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&, _CharT)'
 6127 |     operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
      |     ^~~~~~~~
/usr/include/c++/9/bits/basic_string.h:6127:5: note:   template argument deduction/substitution failed:
circle_selection.cpp:29:31: note:   'circle' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>'
   29 |                 c[j] + c[j + 1];
      |                               ^
In file included from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from circle_selection.cpp:1:
/usr/include/c++/9/complex:327:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator+(const std::complex<_Tp>&, const std::complex<_Tp>&)'
  327 |     operator+(const complex<_Tp>& __x, const complex<_Tp>& __y)
      |     ^~~~~~~~
/usr/include/c++/9/complex:327:5: note:   template argument deduction/substitution failed:
circle_selection.cpp:29:31: note:   'circle' is not derived from 'const std::complex<_Tp>'
   29 |                 c[j] + c[j + 1];
      |                               ^
In file included from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from circle_selection.cpp:1:
/usr/include/c++/9/complex:336:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator+(const std::complex<_Tp>&, const _Tp&)'
  336 |     operator+(const complex<_Tp>& __x, const _Tp& __y)
      |     ^~~~~~~~
/usr/include/c++/9/complex:336:5: note:   template argument deduction/substitution failed:
circle_selection.cpp:29:31: note:   'circle' is not derived from 'const std::complex<_Tp>'
   29 |                 c[j] + c[j + 1];
      |                               ^
In file included from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from circle_selection.cpp:1:
/usr/include/c++/9/complex:345:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator+(const _Tp&, const std::complex<_Tp>&)'
  345 |     operator+(const _Tp& __x, const complex<_Tp>& __y)
      |     ^~~~~~~~
/usr/include/c++/9/complex:345:5: note:   template argument deduction/substitution failed:
circle_selection.cpp:29:31: note:   'circle' is not derived from 'const std::complex<_Tp>'
   29 |                 c[j] + c[j + 1];
      |                               ^
In file included from /usr/include/c++/9/ccomplex:39