Submission #302587

#TimeUsernameProblemLanguageResultExecution timeMemory
302587AmineTrabelsiArranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 KiB
using namespace std; typedef long long ll; #define ff first #define ss second #define em emplace_back #define mp make_pair typedef pair<int,int> ii; const int M = 1e5 + 10; int tree[M*2]; int x; void add(int k,int n){ while(k <= x){ tree[k] += n; k += k& - k; } } int sum(int i){ int res = 0; while(i >= 1){ res += tree[i]; i -= i& - i; } return res; } vector<ii> ord[M]; ll count_swaps(std::vector<int> s){ ll res = 0; x = s.size(); int n = x/2; for(int i=0;i<x;i++){ ord[abs(s[i])].em(mp(s[i],i)); } vector<ii> v; for(int i=1;i<=n;i++){ sort(ord[i].begin(),ord[i].end()); for(int j=0;j<ord[i].size()/2;j++){ int f = ord[i][j].second, s = ord[i][j+(ord[i].size()/2)].second; if(f > s){ swap(f,s); res++; } v.em(mp(f+1,s+1)); } } //cout << res << endl; sort(v.begin(),v.end()); //for(auto i:v)cout << i.ff << " " << i.ss << endl; for(int i=1;i<=n*2;i++)add(i,1); for(auto i:v){ res += sum(i.ss-1)-sum(i.ff); add(i.ss,-1); add(i.ff,-1); } return res; }

Compilation message (stderr)

shoes.cpp:7:9: error: 'pair' does not name a type
    7 | typedef pair<int,int> ii;
      |         ^~~~
shoes.cpp:25:1: error: 'vector' does not name a type
   25 | vector<ii> ord[M];
      | ^~~~~~
shoes.cpp:26:21: error: 'vector' is not a member of 'std'
   26 | ll count_swaps(std::vector<int> s){
      |                     ^~~~~~
shoes.cpp:1:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
  +++ |+#include <vector>
    1 | using namespace std;
shoes.cpp:26:28: error: expected primary-expression before 'int'
   26 | ll count_swaps(std::vector<int> s){
      |                            ^~~