제출 #1369767

#제출 시각아이디문제언어결과실행 시간메모리
1369767moha1111Arranging Shoes (IOI19_shoes)C++20
컴파일 에러
0 ms0 KiB
#include "shoes.h"
#include "bits/stdc++.h"
using namespace std;

long long count_swaps(std::vector<int> s) {
	long long n = s.size() / 2;
	long long mn = 1000000000000000 , mx = 0;
	for(auto i : s)
	{
		mn = min(mn , abs(i));
		mx = max(mx , abs(i));
	}
	if(mn != mx)
		return (n - 1) * n / 2;

	if(n <= 1000)	
	{
		long long i = 0 , ans = 0;
		while(i < 2 * n)
		{
			int bad = -1;
			for(int j = i + 1 ; j < 2 * n ; j++)
			{
				if(s[i] == -s[j])
				{
					bad = i;
					break;
				}
			}
			while(bad != i + 1)
			{
				swap(s[bad] , s[bad - 1]);
				ans++;
				bad--;
			}
			if(s[i] > 0)
			{
				swap(s[i] , s[i + 1]);
				ans++;
			}
			i += 2;
		}
		return ans;
	}
}

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

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:10:25: error: no matching function for call to 'min(long long int&, int)'
   10 |                 mn = min(mn , abs(i));
      |                      ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/13/vector:62,
                 from shoes.h:5,
                 from shoes.cpp:1:
/usr/include/c++/13/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
shoes.cpp:10:25: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   10 |                 mn = min(mn , abs(i));
      |                      ~~~^~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note:   template argument deduction/substitution failed:
shoes.cpp:10:25: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   10 |                 mn = min(mn , abs(i));
      |                      ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from shoes.cpp:2:
/usr/include/c++/13/bits/stl_algo.h:5775:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5775 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5775:5: note:   template argument deduction/substitution failed:
shoes.cpp:10:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   10 |                 mn = min(mn , abs(i));
      |                      ~~~^~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5785:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5785 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5785:5: note:   template argument deduction/substitution failed:
shoes.cpp:10:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   10 |                 mn = min(mn , abs(i));
      |                      ~~~^~~~~~~~~~~~~
shoes.cpp:11:25: error: no matching function for call to 'max(long long int&, int)'
   11 |                 mx = max(mx , abs(i));
      |                      ~~~^~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
shoes.cpp:11:25: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   11 |                 mx = max(mx , abs(i));
      |                      ~~~^~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note:   template argument deduction/substitution failed:
shoes.cpp:11:25: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   11 |                 mx = max(mx , abs(i));
      |                      ~~~^~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5795:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5795 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5795:5: note:   template argument deduction/substitution failed:
shoes.cpp:11:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   11 |                 mx = max(mx , abs(i));
      |                      ~~~^~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5805 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note:   template argument deduction/substitution failed:
shoes.cpp:11:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   11 |                 mx = max(mx , abs(i));
      |                      ~~~^~~~~~~~~~~~~
shoes.cpp:45:1: warning: control reaches end of non-void function [-Wreturn-type]
   45 | }
      | ^