| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 160752 | davitmarg | Sorting (IOI15_sorting) | C++17 | 컴파일 에러 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*DavitMarg*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <list>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <stack>
#include <cassert>
#include <iterator>
#include <fstream>
#define mod 1000000007ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
#define all(v) v.begin(), v.end()
using namespace std;
#ifndef death
#include "sorting.h"
#endif
const int N = 200005;
int n,q,x[3*N],y[3*N];
vector<int> s,pos;
vector<pair<int,int>> solve(int r)
{
vector<int> a=s,p=s;
vector<pair<int,int>> ans;
for(int i=0;i<r;i++)
swap(a[x[i]],a[y[i]]);
for(int i=0;i<n;i++)
p[i]=pos[a[i]];
a=s;
for(int i=0;i<n;i++)
{
//cout<<p[i]<<" ,";
if(i!=p[a[i]])
{
ans.PB(MP(p[a[i]],i));
swap(a[p[a[i]]],a[i]);
}
}
return ans;
}
int findSwapPairs(int N,int S[],int M,int X[],int Y[],int P[],int Q[])
{
n=N;
for(int i=0;i<n;i++)
s.PB(S[i]);
pos=s;
for(int i=0;i<n;i++)
pos[s[i]]=i;
q=M;
for(int i=0;i<q;i++)
{
x[i]=X[i];
y[i]=Y[i];
}
int l=0,r=m,m,pos;
while(l<=r)
{
m=(l+r)/2;
vector<pair<int,int>> ans=solve(m);
if(ans.size()<=m)
{
pos=m;
r=m-1;
}
else
l=m+1;
}
vector<pair<int,int>> ans=solve(pos);
while(ans.size()<pos)
ans.PB(MP(0,0));
for(int j=0;j<ans.size();j++)
{
P[j]=ans[j].first;
Q[j]=ans[j].second;
}
return pos;
}
#ifdef death
int main()
{
int N,S[102],M,X[102],Y[102],P[102],Q[102],R;
cin>>N;
for(int i=0;i<N;i++)
cin>>S[i];
cin>>M;
for(int i=0;i<M;i++)
cin>>X[i]>>Y[i];
R=findSwapPairs(N,S,M,X,Y,P,Q);
cout<<R<<endl;
for(int i=0;i<R;i++)
cout<<P[i]<<" : "<<Q[i]<<endl;
return 0;
}
#endif
/*
3
0 2 1
3
0 0
1 1
1 0
5
3 0 4 2 1
5
1 1
4 0
2 3
1 4
0 4
2 0
4 0
4 1
2 3
1 4
0 4
0 1 3 2 4
*/
컴파일 시 표준 에러 (stderr) 메시지
sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:60:70: warning: declaration of 'N' shadows a global declaration [-Wshadow]
int findSwapPairs(int N,int S[],int M,int X[],int Y[],int P[],int Q[])
^
sorting.cpp:32:11: note: shadowed declaration is here
const int N = 200005;
^
sorting.cpp:74:15: error: 'm' was not declared in this scope
int l=0,r=m,m,pos;
^
sorting.cpp:88:37: error: cannot convert 'std::vector<int>' to 'int' for argument '1' to 'std::vector<std::pair<int, int> > solve(int)'
vector<pair<int,int>> ans=solve(pos);
^
sorting.cpp:89:18: error: no match for 'operator<' (operand types are 'std::vector<std::pair<int, int> >::size_type {aka long unsigned int}' and 'std::vector<int>')
while(ans.size()<pos)
~~~~~~~~~~^~~~
In file included from /usr/include/c++/7/bits/stl_algobase.h:64:0,
from /usr/include/c++/7/bits/char_traits.h:39,
from /usr/include/c++/7/ios:40,
from /usr/include/c++/7/ostream:38,
from /usr/include/c++/7/iostream:39,
from sorting.cpp:2:
/usr/include/c++/7/bits/stl_pair.h:449:5: note: candidate: template<class _T1, class _T2> constexpr bool std::operator<(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&)
operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
^~~~~~~~
/usr/include/c++/7/bits/stl_pair.h:449:5: note: template argument deduction/substitution failed:
sorting.cpp:89:19: note: mismatched types 'const std::pair<_T1, _T2>' and 'std::vector<std::pair<int, int> >::size_type {aka long unsigned int}'
while(ans.size()<pos)
^~~
In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0,
from /usr/include/c++/7/bits/char_traits.h:39,
from /usr/include/c++/7/ios:40,
from /usr/include/c++/7/ostream:38,
from /usr/include/c++/7/iostream:39,
from sorting.cpp:2:
/usr/include/c++/7/bits/stl_iterator.h:305:5: note: candidate: template<class _Iterator> constexpr bool std::operator<(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&)
operator<(const reverse_iterator<_Iterator>& __x,
^~~~~~~~
/usr/include/c++/7/bits/stl_iterator.h:305:5: note: template argument deduction/substitution failed:
sorting.cpp:89:19: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'std::vector<std::pair<int, int> >::size_type {aka long unsigned int}'
while(ans.size()<pos)
^~~
In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0,
from /usr/include/c++/7/bits/char_traits.h:39,
from /usr/include/c++/7/ios:40,
from /usr/include/c++/7/ostream:38,
from /usr/include/c++/7/iostream:39,
from sorting.cpp:2:
/usr/include/c++/7/bits/stl_iterator.h:343:5: note: candidate: template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_IteratorR>&)
operator<(const reverse_iterator<_IteratorL>& __x,
^~~~~~~~
/usr/include/c++/7/bits/stl_iterator.h:343:5: note: template argument deduction/substitution failed:
sorting.cpp:89:19: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'std::vector<std::pair<int, int> >::size_type {aka long unsigned int}'
while(ans.size()<pos)
^~~
In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0,
from /usr/include/c++/7/bits/char_traits.h:39,
from /usr/include/c++/7/ios:40,
from /usr/include/c++/7/ostream:38,
from /usr/include/c++/7/iostream:39,
from sorting.cpp:2:
/usr/include/c++/7/bits/stl_iterator.h:1142:5: note: candidate: template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const std::move_iterator<_IteratorL>&, const std::move_iterator<_IteratorR>&)
operator<(const move_iterator<_IteratorL>& __x,
^~~~~~~~
/usr/include/c++/7/bits/stl_iterator.h:1142:5: note: template argument deduction/substitution failed:
sorting.cpp:89:19: note: mismatched types 'const std::move_iterator<_IteratorL>' and 'std::vector<std::pair<int, int> >::size_type {aka long unsigned int}'
while(ans.size()<pos)
^~~
In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0,
from /usr/include/c++/7/bits/char_traits.h:39,
from /usr/include/c++/7/ios:40,
from /usr/include/c++/7/ostream:38,
from /usr/include/c++/7/iostream:39,
from sorting.cpp:2:
/usr/include/c++/7/bits/stl_iterator.h:1148:5: note: candidate: template<class _Iterator> constexpr bool std::operator<(const std::move_iterator<_IteratorL>&, const std::move_iterator<_IteratorL>&)
operator<(const move_iterator<_Iterator>& __x,
^~~~~~~~
/usr/include/c++/7/bits/stl_iterator.h:1148:5: note: template argument deduction/substitution failed:
sorting.cpp:89:19: note: mismatched types 'const std::move_iterator<_IteratorL>' and 'std::vector<std::pair<int, int> >::size_type {aka long unsigned int}'
while(ans.size()<pos)
^~~
In file included from /usr/include/c++/7/bits/basic_string.h:48:0,
from /usr/include/c++/7/string:52,
from /usr/include/c++/7/bits/locale_classes.h:40,
from /usr/include/c++/7/bits/ios_base.h:41,
from /usr/include/c++/7/ios:42,
from /usr/include/c++/7/ostream:38,
from /usr/include/c++/7/iostream:39,
from sorting.cpp:2:
/usr/include/c++/7/string_view:486:5: note: candidate: template<class _CharT, class _Traits> constexpr bool std::operator<(std::basic_string_view<_CharT, _Traits>, std::basic_string_view<_CharT, _Traits>)
operator< (basic_string_view<_CharT, _Traits> __x,
^~~~~~~~
/usr/include/c++/7/string_view:486:5: note: template argument deduction/substitution failed:
sorting.cpp:89:19: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'long unsigned int'
while(ans.size()<pos)
^~~
In file included from /usr/include/c++/7/bits/basic_string.h:48:0,
from /usr/include/c++/7/string:52,
from /usr/include/c++/7/bits/locale_classes.h:40,
from /usr/include/c++/7/bits/ios_base.h:41,
from /usr/include/c++/7/ios:42,
from /usr/include/c++/7/ostream:38,
from /usr/include/c++/7/iostream:39,
from sorting.cpp:2:
/usr/include/c++/7/string_view:492:5: note: candidate: template<class _CharT, class _Traits> constexpr bool std::operator<(std::basic_string_view<_CharT, _Traits>, std::__detail::__idt<std::basic_string_view<_CharT, _Traits> >)
operator< (basic_string_view<_CharT, _Traits> __x,
^~~~~~~~
/usr/include/c++/7/string_view:492:5: note: template argument deduction/substitution failed:
sorting.cpp:89:19: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'long unsigned int'
while(ans.size()<pos)
^~~
In file included from /usr/include/c++/7/bits/basic_string.h:48:0,
from /usr/include/c++/7/string:52,
from /usr/include/c++/7/bits/locale_classes.h:40,
from /usr/include/c++/7/bits/ios_base.h:41,
from /usr/include/c++/7/ios:42,
from /usr/include/c++/7/ostream:38,
from /usr/include/c++/7/iostream:39,
from sorting.cpp:2:
/usr/include/c++/7/string_view:498:5: note: candidate: template<class _CharT, class _Traits> constexpr bool std::operator<(std::__detail::__idt<std::basic_string_view<_CharT, _Traits> >, std::basic_string_view<_CharT, _Traits>)
operator< (__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
^~~~~~~~
/usr/include/c++/7/string_view:498:5: note: template argument deduction/substitution failed:
sorting.cpp:89:19: note: 'std::vector<int>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
while(ans.size()<pos)
^~~
In file included from /usr/include/c++/7/string:52:0,
from /usr/include/c++/7/bits/locale_classes.h:40,
from /usr/include/c++/7/bits/ios_base.h:41,
from /usr/include/c++/7/ios:42,
from /usr/include/c++/7/ostream:38,
from /usr/include/c++/7/iostream:39,
from sorting.cpp:2:
/usr/include/c++/7/bits/basic_string.h:6082:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&)
operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
^~~~~~~~
/usr/include/c++/7/bits/basic_string.h:6082:5: note: template argument deduction/substitution failed:
sorting.cpp:89:19: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'std::vector<std::pair<int, int> >::size_type {aka long unsigned int}'
while(ans.size()<pos)
^~~
In file included from /usr/include/c++/7/string:52:0,
from /usr/include/c++/7/bits/locale_classes.h:40,
from /usr/include/c++/7/bits/ios_base.h:41,
from /usr/include/c++/7/ios:42,
from /usr/include/c++/7/ostream:38,
from /usr/include/c++/7/iostream:39,
from sorting.cpp:2:
/usr/include/c++/7/bits/basic_string.h:6095:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*)
operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
^~~~~~~~
/usr/include/c++/7/bits/basic_string.h:6095:5: note: template argument deduction/substitution failed:
sorting.cpp:89:19: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'std::vector<std::pair<int, int> >::size_type {aka long unsigned int}'
while(ans.size()<pos)
^~~
In file included from /usr/include/c++/7/string:52:0,
from /usr/include/c++/7/bits/locale_classes.h:40,
from /usr/include/c++/7/bits/ios_base.h:41,
from /usr/include/c++/7/ios:42,
from /usr/include/c++/7/ostream:38,
from /usr/include/c++/7/iostream:39,
from sorting.cpp:2:
/usr/include/c++/7/bits/basic_string.h:6107:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const _CharT*, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&)
operator<(const _CharT* __lhs,
^~~~~~~~
/usr/include/c++/7/bits/basic_string.h:6107:5: note: template argument deduction/substitution failed:
sorting.cpp:89:19: note: mismatched types 'const _CharT*' and 'long unsigned int'
while(ans.size()<pos)
^~~
In file included from /usr/include/c++/7/bits/ios_base.h:46:0,
from /usr/include/c++/7/ios:42,
from /usr/include/c++/7/ostream:38,
from /usr/include/c++/7/iostream:39,
from sorting.cpp:2:
/usr/include/c++/7/system_error:208:3: note: candidate: bool std::operator<(const std::error_code&, const std::error_code&)
operator<(const error_code& __lhs, const error_code& __rhs) noexcept
^~~~~~~~
/usr/include/c++/7/system_error:208:3: note: no known conversion for argument 1 from 'std::vector<std::pair<int, int> >::size_type {aka long unsigned int}' to 'const std::error_code&'
/usr/include/c++/7/system_error:282:3: note: candidate: bool std::operator<(const std::error_condition&, const std::error_condition&)
operator<(const error_condition& __lhs,
^~~~~~~~
/usr/include/c++/7/system_error:282:3: note: no known conversion for argument 1 from 'std::vector<std::pair<int, int> >::size_type {aka long unsigned int}' to 'const std::error_condition&'
In file included from /usr/include/c++/7/vector:64:0,
from sorting.cpp:6:
/usr/include/c++/7/bits/stl_vector.h:1613:5: note: candidate: template<class _Tp, class _Alloc> bool std::operator<(const std::vector<_Tp, _Alloc>&, const std::vector<_Tp, _Alloc>&)
operator<(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
^~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:1613:5: note: template argument deduction/substitution failed:
sorting.cpp:89:19: note: mismatched types 'const std::vector<_Tp, _Alloc>' and 'std::vector<std::pair<int, int> >::size_type {aka long unsigned int}'
while(ans.size()<pos)
^~~
In file included from /usr/include/c++/7/list:63:0,
from sorting.cpp:9:
/usr/include/c++/7/bits/stl_list.h:1918:5: note: candidate: template<class _Tp, class _Alloc> bool std::operator<(const std::__cxx11::list<_Tp, _Alloc>&, const std::__cxx11::list<_Tp, _Alloc>&)
operator<(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
^~~~~~~~
/usr/include/c++/7/bits/stl_list.h:1918:5: note: template argument deduction/substitution failed:
sorting.cpp:89:19: note: mismatched types 'const std::__cxx11::list<_Tp, _Alloc>' and 'std::vector<std::pair<int, int> >::size_type {aka long unsigned int}'
while(ans.size()<pos)
^~~
In file included from /usr/include/c++/7/bits/node_handle.h:39:0,
from /usr/include/c++/7/bits/stl_tree.h:72,
from /usr/include/c++/7/map:60,
from sorting.cpp:10:
/usr/include/c++/7/optional:810:5: note: candidate: template<class _Tp, class _Up> constexpr std::__optional_relop_t<decltype ((declval<_Tp>() < declval<_Up>()))> std::operator<(const std::optional<_Tp>&, const std::optional<_Up>&)
operator<(const optional<_Tp>& __lhs, const optional<_Up>& __rhs)
^~~~~~~~
/usr/include/c++/7/optional:810:5: note: template argument deduction/substitution failed:
sorting.cpp:89:19: note: mismatched types 'const std::optional<_Tp>' and 'std::vector<std::pair<int, int> >::size_type {aka long unsigned int}'
while(ans.size()<pos)
^~~
In file included from /usr/include/c++/7/bits/node_handle.h:39:0,
from /usr/include/c++/7/bits/stl_tree.h:72,
from /usr/include/c++/7/map:60,
from sorting.cpp:10:
/usr/include/c++/7/optional:863:5: note: candidate: template<class _Tp> constexpr bool std::operator<(const std::optional<_Tp>&, std::nullopt_t)
operator<(const optional<_Tp>& /* __lhs */, nullopt_t) noexcept
^~~~~~~~
/usr/include/c++/7/optional:863:5: note: template argument deduction/substitution failed:
sorting.cpp:89:19: note: mismatched types 'const std::optional<_Tp>' and 'std::vector<std::pair<int, int> >::size_type {aka long unsigned int}'
while(ans.size()<pos)
^~~
In file included from /usr/include/c++/7/bits/node_handle.h:39:0,
from /usr/include/c++/7/bits/stl_tree.h:72,
from /usr/include/c++/7/map:60,
from sorting.cpp:10:
/usr/include/c++/7/optional:868:5: note: candidate: template<class _Tp> constexpr bool std::operator<(std::nullopt_t, const std::optional<_Tp>&)
operator<(nullopt_t, const optional<_Tp>& __rhs) noexcept
^~~~~~~~
/usr/include/c++/7/optional:868:5: note: template argument deduction/substitution failed:
sorting.cpp:89:19: note: 'std::vector<int>' is not derived from 'const std::optional<_Tp>'
while(ans.size()<pos)
^~~
In file included from /usr/include/c++/7/bits/node_handle.h:39:0,
from /usr/include/c++/7/bits/stl_tree.h:72,
from /usr/include/c++/7/map:60,
from sorting.cpp:10:
/usr/include/c++/7/optional:928:5: note: candidate: template<class _Tp, class _Up> constexpr std::__optional_relop_t<decltype ((declval<_Tp>() < declval<_Up>()))> std::operator<(const std::optional<_Tp>&, const _Up&)
operator<(const optional<_Tp>& __lhs, const _Up& __rhs)
^~~~~~~~
/usr/include/c++/7/optional:928:5: note: template argument deduction/substitution failed:
sorting.cpp:89:19: note: mismatched types 'const std::optional<_Tp>' and 'std::vector<std::pair<int, int> >::size_type {aka long unsigned int}'
while(ans.size()<pos)
^~~
In file included from /usr/include/c++/7/bits/node_handle.h:39:0,
from /usr/include/c++/7/bits/stl_tree.h:72,
from /usr/include/c++/7/map:60,
from sorting.cpp:10:
/usr/include/c++/7/optional:934:5: note: candidate: template<class _Tp, class _Up> constexpr std::__optional_relop_t<decltype ((declval<_Up>() < declval<_Tp>()))> std::operator<(const _Up&, const std::optional<_Tp>&)
operator<(const _Up& __lhs, const optional<_Tp>& __rhs)
^~~~~~~~
/usr/include/c++/7/optional:934:5: note: template argument deduction/substitution failed:
sorting.cpp:89:19: note: 'std::vector<int>' is not derived from 'const std::optional<_Tp>'
while(ans.size()<pos)
^~~
In file included from /usr/include/c++/7/map:60:0,
from sorting.cpp:10:
/usr/include/c++/7/bits/stl_tree.h:1543:5: note: candidate: template<class _Key, class _Val, class _KeyOfValue, class _Compare, class _Alloc> bool std::operator<(const std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&, const std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&)
operator<(const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x,
^~~~~~~~
/usr/include/c++/7/bits/stl_tree.h:1543:5: note: template argument deduction/substitution failed:
sorting.cpp:89:19: note: mismatched types 'const std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>' and 'std::vector<std::pair<int, int> >::size_type {aka long unsigned int}'
while(ans.size()<pos)
^~~
In file included from /usr/include/c++/7/tuple:39:0,
from /usr/include/c++/7/bits/stl_map.h:63,
from /usr/include/c++/7/map:61,
from sorting.cpp:10:
/usr/include/c++/7/array:262:5: note: candidate: template<class _Tp, long unsigned int _Nm> bool std::operator<(const std::array<_Tp, _Nm>&, const std::array<_Tp, _Nm>&)
operator<(const array<_Tp, _Nm>& __a, const array<_Tp, _Nm>& __b)
^~~~~~~~
/usr/include/c++/7/array:262:5: