Submission #143373

#TimeUsernameProblemLanguageResultExecution timeMemory
143373ondrahArranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 KiB
#include <iostream> using namespace std; #include <ext/pb_ds/detail/standard_policies.hpp> #include <set> #include <map> using namespace std; typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; long long count_swaps(std::vector<int> s) { long long ans = 0; int n = s.size(); ordered_set<int> els; map<int, multiset<int>> M; for(int i = 0; i < n; i++) { els.insert(i); M[s[i]].insert(i); } for(int i = 0; i < n; i++) { if(s[i] == n+2) continue; int j = *M[-s[i]].begin(); M[-s[i]].erase(M[-s[i]].begin()); int pos1 = els.order_of_key(i); int pos2 = els.order_of_key(j); els.erase(els.find(j)); ans += pos2-pos1; if(s[i] > 0) ans++; break; } return ans; } int main() { // your code goes here return 0; }

Compilation message (stderr)

shoes.cpp:8:9: error: 'tree' does not name a type; did you mean 'free'?
 typedef tree<
         ^~~~
         free
shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:19:2: error: 'ordered_set' was not declared in this scope
  ordered_set<int> els;
  ^~~~~~~~~~~
shoes.cpp:19:14: error: expected primary-expression before 'int'
  ordered_set<int> els;
              ^~~
shoes.cpp:22:3: error: 'els' was not declared in this scope
   els.insert(i);
   ^~~
shoes.cpp:30:14: error: 'els' was not declared in this scope
   int pos1 = els.order_of_key(i);
              ^~~