| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1155461 | at128 | Arranging Shoes (IOI19_shoes) | C++20 | 컴파일 에러 | 0 ms | 0 KiB |
#include "shoes.h"
#include<bits/stdc++.h>
#include<vector>
#include<map>
#include<iostream>
long long count_swaps(std::vector<int> s) {
int n;
n=s.size()/2;
vector<int>v(2*n);
map<int,set<int>>m;
for(int i=0;i<2*n;i++){
v[i]=s[i];
m[v[i]].insert(i);
}
ll res=0,c=0;
vector<int>s;
for(int i=0;i<2*n;i++){
if(v[i]==INT_MAX){
continue;
}
if(v[i]>0){
int j=*m[-v[i]].begin();
v[j]=INT_MAX;
int p1=(s.end()- lower_bound(all(s),i));
int p2=(s.end()- lower_bound(all(s),j));
s.pb(j);
m[-v[i]].erase(m[-v[i]].begin());
res+=(j-i-(p2-p1));
}else{
int j=*m[-v[i]].begin();
v[j]=INT_MAX;
int p1=(s.end()-lower_bound(all(s),i));
int p2=(s.end()- lower_bound(all(s),j));
s.pb(j);
m[-v[i]].erase(m[-v[i]].begin());
res+=(j-i-(p2-p1)-1);
}
m[v[i]].erase(i);
}
return res;
}
컴파일 시 표준 에러 (stderr) 메시지
shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:10:5: error: 'vector' was not declared in this scope
10 | vector<int>v(2*n);
| ^~~~~~
shoes.cpp:10:5: note: suggested alternatives:
In file included from /usr/include/c++/11/vector:67,
from shoes.h:5,
from shoes.cpp:1:
/usr/include/c++/11/bits/stl_vector.h:389:11: note: 'std::vector'
389 | class vector : protected _Vector_base<_Tp, _Alloc>
| ^~~~~~
In file included from shoes.h:5,
from shoes.cpp:1:
/usr/include/c++/11/vector:86:13: note: 'std::pmr::vector'
86 | using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
| ^~~~~~
shoes.cpp:10:12: error: expected primary-expression before 'int'
10 | vector<int>v(2*n);
| ^~~
shoes.cpp:11:13: error: 'set' was not declared in this scope
11 | map<int,set<int>>m;
| ^~~
shoes.cpp:11:13: note: suggested alternatives:
In file included from /usr/include/c++/11/set:61,
from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:87,
from shoes.cpp:2:
/usr/include/c++/11/bits/stl_set.h:94:11: note: 'std::set'
94 | class set
| ^~~
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:87,
from shoes.cpp:2:
/usr/include/c++/11/set:78:13: note: 'std::pmr::set'
78 | using set = std::set<_Key, _Cmp, polymorphic_allocator<_Key>>;
| ^~~
shoes.cpp:11:5: error: 'map' was not declared in this scope
11 | map<int,set<int>>m;
| ^~~
shoes.cpp:11:5: note: suggested alternatives:
In file included from /usr/include/c++/11/map:61,
from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:81,
from shoes.cpp:2:
/usr/include/c++/11/bits/stl_map.h:100:11: note: 'std::map'
100 | class map
| ^~~
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:81,
from shoes.cpp:2:
/usr/include/c++/11/map:78:13: note: 'std::pmr::map'
78 | using map
| ^~~
shoes.cpp:11:9: error: expected primary-expression before 'int'
11 | map<int,set<int>>m;
| ^~~
shoes.cpp:13:9: error: 'v' was not declared in this scope
13 | v[i]=s[i];
| ^
shoes.cpp:14:9: error: 'm' was not declared in this scope
14 | m[v[i]].insert(i);
| ^
shoes.cpp:16:5: error: 'll' was not declared in this scope
16 | ll res=0,c=0;
| ^~
shoes.cpp:17:12: error: expected primary-expression before 'int'
17 | vector<int>s;
| ^~~
shoes.cpp:19:12: error: 'v' was not declared in this scope
19 | if(v[i]==INT_MAX){
| ^
shoes.cpp:22:12: error: 'v' was not declared in this scope
22 | if(v[i]>0){
| ^
shoes.cpp:23:20: error: 'm' was not declared in this scope
23 | int j=*m[-v[i]].begin();
| ^
shoes.cpp:25:42: error: 'all' was not declared in this scope
25 | int p1=(s.end()- lower_bound(all(s),i));
| ^~~
shoes.cpp:25:42: note: suggested alternatives:
In file included from /usr/include/c++/11/filesystem:44,
from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:129,
from shoes.cpp:2:
/usr/include/c++/11/bits/fs_fwd.h:154:7: note: 'std::filesystem::perms::all'
154 | all = 0777,
| ^~~
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:146,
from shoes.cpp:2:
/usr/include/c++/11/ranges:1130:27: note: 'std::ranges::views::all'
1130 | inline constexpr _All all;
| ^~~
shoes.cpp:25:30: error: 'lower_bound' was not declared in this scope
25 | int p1=(s.end()- lower_bound(all(s),i));
| ^~~~~~~~~~~
shoes.cpp:25:30: note: suggested alternatives:
In file included from /usr/include/c++/11/vector:62,
from shoes.h:5,
from shoes.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:2011:5: note: 'std::lower_bound'
2011 | lower_bound(_ForwardIterator __first, _ForwardIterator __last,
| ^~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:64,
from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
from shoes.cpp:2:
/usr/include/c++/11/bits/ranges_algo.h:2124:37: note: 'std::ranges::lower_bound'
2124 | inline constexpr __lower_bound_fn lower_bound{};
| ^~~~~~~~~~~
shoes.cpp:27:15: error: 'class std::vector<int>' has no member named 'pb'
27 | s.pb(j);
| ^~
shoes.cpp:29:13: error: 'res' was not declared in this scope
29 | res+=(j-i-(p2-p1));
| ^~~
shoes.cpp:31:20: error: 'm' was not declared in this scope
31 | int j=*m[-v[i]].begin();
| ^
shoes.cpp:33:41: error: 'all' was not declared in this scope
33 | int p1=(s.end()-lower_bound(all(s),i));
| ^~~
shoes.cpp:33:41: note: suggested alternatives:
In file included from /usr/include/c++/11/filesystem:44,
from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:129,
from shoes.cpp:2:
/usr/include/c++/11/bits/fs_fwd.h:154:7: note: 'std::filesystem::perms::all'
154 | all = 0777,
| ^~~
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:146,
from shoes.cpp:2:
/usr/include/c++/11/ranges:1130:27: note: 'std::ranges::views::all'
1130 | inline constexpr _All all;
| ^~~
shoes.cpp:33:29: error: 'lower_bound' was not declared in this scope
33 | int p1=(s.end()-lower_bound(all(s),i));
| ^~~~~~~~~~~
shoes.cpp:33:29: note: suggested alternatives:
In file included from /usr/include/c++/11/vector:62,
from shoes.h:5,
from shoes.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:2011:5: note: 'std::lower_bound'
2011 | lower_bound(_ForwardIterator __first, _ForwardIterator __last,
| ^~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:64,
from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
from shoes.cpp:2:
/usr/include/c++/11/bits/ranges_algo.h:2124:37: note: 'std::ranges::lower_bound'
2124 | inline constexpr __lower_bound_fn lower_bound{};
| ^~~~~~~~~~~
shoes.cpp:35:15: error: 'class std::vector<int>' has no member named 'pb'
35 | s.pb(j);
| ^~
shoes.cpp:37:13: error: 'res' was not declared in this scope
37 | res+=(j-i-(p2-p1)-1);
| ^~~
shoes.cpp:40:9: error: 'm' was not declared in this scope
40 | m[v[i]].erase(i);
| ^
shoes.cpp:40:11: error: 'v' was not declared in this scope
40 | m[v[i]].erase(i);
| ^
shoes.cpp:42:12: error: 'res' was not declared in this scope
42 | return res;
| ^~~