제출 #303609

#제출 시각아이디문제언어결과실행 시간메모리
303609medmdg카니발 티켓 (IOI20_tickets)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "tickets.h" using namespace std; unsigned long long int fin(vector<vector<int> > a,int n,int m,int k){ unsigned long long int ans=0; for(int i=0;i<n;i++){ unsigned long long int mid=0; for(int j=0;j<m;j++){ mid+=a[i][j]; } mid/=m; unsigned long long int ff=0; for(int j=0;j<m;j++){ if(abs(ff-mid)>abs(a[i][j]-mid)){ ff=a[i][j]; } } for(int j=0;j<m;j++){ ans+=abs(ff-a[i][j]); } } return ans; } long long int find_maximum(int k, vector<vector<int> > x){ int n=x.size(); int m=x[0].size(); if(m==1){ vector<vector<int> > ans(n); vector<vector<int> > answ(k); for(int i=0;i<n;i++){ ans[i].push_back(0); answ[0].push_back(x[i][0]); } allocate_tickets(ans); return fin(answ,k,n,k); } }

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

tickets.cpp: In function 'long long unsigned int fin(std::vector<std::vector<int> >, int, int, int)':
tickets.cpp:14:26: error: call of overloaded 'abs(long long unsigned int)' is ambiguous
   14 |             if(abs(ff-mid)>abs(a[i][j]-mid)){
      |                          ^
In file included from /usr/include/c++/9/bits/std_abs.h:38,
                 from /usr/include/c++/9/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from tickets.cpp:1:
/usr/include/stdlib.h:774:12: note: candidate: 'int abs(int)'
  774 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |            ^~~
In file included from /usr/include/c++/9/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from tickets.cpp:1:
/usr/include/c++/9/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
   79 |   abs(long double __x)
      |   ^~~
/usr/include/c++/9/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
   75 |   abs(float __x)
      |   ^~~
/usr/include/c++/9/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
   71 |   abs(double __x)
      |   ^~~
/usr/include/c++/9/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
   61 |   abs(long long __x) { return __builtin_llabs (__x); }
      |   ^~~
/usr/include/c++/9/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
   56 |   abs(long __i) { return __builtin_labs(__i); }
      |   ^~~
tickets.cpp:14:43: error: call of overloaded 'abs(long long unsigned int)' is ambiguous
   14 |             if(abs(ff-mid)>abs(a[i][j]-mid)){
      |                                           ^
In file included from /usr/include/c++/9/bits/std_abs.h:38,
                 from /usr/include/c++/9/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from tickets.cpp:1:
/usr/include/stdlib.h:774:12: note: candidate: 'int abs(int)'
  774 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |            ^~~
In file included from /usr/include/c++/9/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from tickets.cpp:1:
/usr/include/c++/9/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
   79 |   abs(long double __x)
      |   ^~~
/usr/include/c++/9/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
   75 |   abs(float __x)
      |   ^~~
/usr/include/c++/9/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
   71 |   abs(double __x)
      |   ^~~
/usr/include/c++/9/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
   61 |   abs(long long __x) { return __builtin_llabs (__x); }
      |   ^~~
/usr/include/c++/9/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
   56 |   abs(long __i) { return __builtin_labs(__i); }
      |   ^~~
tickets.cpp:19:32: error: call of overloaded 'abs(long long unsigned int)' is ambiguous
   19 |             ans+=abs(ff-a[i][j]);
      |                                ^
In file included from /usr/include/c++/9/bits/std_abs.h:38,
                 from /usr/include/c++/9/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from tickets.cpp:1:
/usr/include/stdlib.h:774:12: note: candidate: 'int abs(int)'
  774 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |            ^~~
In file included from /usr/include/c++/9/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from tickets.cpp:1:
/usr/include/c++/9/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
   79 |   abs(long double __x)
      |   ^~~
/usr/include/c++/9/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
   75 |   abs(float __x)
      |   ^~~
/usr/include/c++/9/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
   71 |   abs(double __x)
      |   ^~~
/usr/include/c++/9/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
   61 |   abs(long long __x) { return __builtin_llabs (__x); }
      |   ^~~
/usr/include/c++/9/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
   56 |   abs(long __i) { return __builtin_labs(__i); }
      |   ^~~
tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:37:1: warning: control reaches end of non-void function [-Wreturn-type]
   37 | }
      | ^