제출 #1274333

#제출 시각아이디문제언어결과실행 시간메모리
1274333coderg300711Aliens (IOI16_aliens)C++20
컴파일 에러
0 ms0 KiB
#include "aliens.h" #include <bits/stdc++.h> using namespace std; using ll = long long; #define all(x) (x).begin(), (x).end() #define sz(x) int(x.size()) long long take_photos(int n, int m, int K,vector<int> r,vector<int> c) { vector<pair<int, int>> pts(n); for(int i=0;i<n;i++){ if (r[i]>c[i])swap(r[i],c[i]); pts[i]=({r[i],c[i]}); } sort(all(pts)); { vector<pair<int, int>> pts2; for(int i=0;i<n;i++) { if (i!=n-1 && pts[i].first==pts[i+1].first)continue; pts2.push_back(pts[i]); } pts=pts2; n=sz(pts); } { vector<pair<int, int>> pts2; int mx_c=-1; for(int i=0;i<n;i++) { if(pts[i].second<=mx_c)continue; pts2.push_back(pts[i]); mx_c=max(mx_c,pts[i].second); } pts=pts2; n=sz(pts); } vector<vector<ll>> dp(n+1,vector<ll>(K+1,1LL<<60)); dp[0][0]=0; for(int i=1;i<=n;i++){ for(int j=0;j<i;j++){ ll diff=pts[i-1].second-pts[j].first+1; ll cost=diff*diff; for(int k=0;k<K;k++)dp[i][k+1]=min(dp[i][k+1],dp[j][k]+cost); } } ll ans=1LL<<60; for(int i=0;i<=K;i++)ans=min(ans,dp[n][i]); return ans; }

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

aliens.cpp: In function 'long long int take_photos(int, int, int, std::vector<int>, std::vector<int>)':
aliens.cpp:12:21: warning: ignoring return value of 'constexpr std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = int; _Alloc = std::allocator<int>; reference = int&; size_type = long unsigned int]', declared with attribute 'nodiscard' [-Wunused-result]
   12 |         pts[i]=({r[i],c[i]});
      |                     ^
In file included from /usr/include/c++/13/vector:66,
                 from aliens.h:3,
                 from aliens.cpp:1:
/usr/include/c++/13/bits/stl_vector.h:1126:7: note: declared here
 1126 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
aliens.cpp:12:27: error: expected ';' before '}' token
   12 |         pts[i]=({r[i],c[i]});
      |                           ^
      |                           ;
aliens.cpp:12:28: error: no match for 'operator=' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   12 |         pts[i]=({r[i],c[i]});
      |                            ^
In file included from /usr/include/c++/13/bits/stl_algobase.h:64,
                 from /usr/include/c++/13/vector:62:
/usr/include/c++/13/bits/stl_pair.h:439:9: note: candidate: 'template<class _U1, class _U2> constexpr std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(const std::pair<_U1, _U2>&) requires  _S_assignable<const _U1&, const _U2&>() [with _U2 = _U1; _T1 = int; _T2 = int]'
  439 |         operator=(const pair<_U1, _U2>& __p)
      |         ^~~~~~~~
/usr/include/c++/13/bits/stl_pair.h:439:9: note:   template argument deduction/substitution failed:
aliens.cpp:12:28: note:   mismatched types 'const std::pair<_T1, _T2>' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   12 |         pts[i]=({r[i],c[i]});
      |                            ^
/usr/include/c++/13/bits/stl_pair.h:451:9: note: candidate: 'template<class _U1, class _U2> constexpr std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(std::pair<_U1, _U2>&&) requires  _S_assignable<_U1, _U2>() [with _U2 = _U1; _T1 = int; _T2 = int]'
  451 |         operator=(pair<_U1, _U2>&& __p)
      |         ^~~~~~~~
/usr/include/c++/13/bits/stl_pair.h:451:9: note:   template argument deduction/substitution failed:
aliens.cpp:12:28: note:   mismatched types 'std::pair<_T1, _T2>' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   12 |         pts[i]=({r[i],c[i]});
      |                            ^
/usr/include/c++/13/bits/stl_pair.h:416:7: note: candidate: 'constexpr std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(const std::pair<_T1, _T2>&) requires  _S_assignable<const _T1&, const _T2&>() [with _T1 = int; _T2 = int]'
  416 |       operator=(const pair& __p)
      |       ^~~~~~~~
/usr/include/c++/13/bits/stl_pair.h:416:29: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} to 'const std::pair<int, int>&'
  416 |       operator=(const pair& __p)
      |                 ~~~~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_pair.h:427:7: note: candidate: 'constexpr std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(std::pair<_T1, _T2>&&) requires  _S_assignable<_T1, _T2>() [with _T1 = int; _T2 = int]'
  427 |       operator=(pair&& __p)
      |       ^~~~~~~~
/usr/include/c++/13/bits/stl_pair.h:427:24: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} to 'std::pair<int, int>&&'
  427 |       operator=(pair&& __p)
      |                 ~~~~~~~^~~
aliens.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
aliens_c.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~