Submission #219168

#TimeUsernameProblemLanguageResultExecution timeMemory
219168sidiq_haArranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include "shoes.h" #define pb push_back #define fi first #define se second #define mp make_pair #define all(v) v.begin(), v.end() using namespace std; typedef long long LL; const LL MOD = 1e9 + 7; const double PI = 2 * acos(0); using namespace __gnu_pbds; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set; //order_of_key(x) = number of elements stricly smaller than x //find_by_order(x) = return x-th largest element bitset<121212> flag; long long count_swaps(vector<int> s) { new_data_set tmp; int n = s.size(); LL ans2 = 0; vector<int> ans; for (int i = 0; i < n; i++) { if (s[i] < 0) kiri[-s[i]].push(i); else kanan[s[i]].push(i); } for (int i = 0; i < n; i++) { if (!flag[i]) { if (s[i] < 0) { int x = -s[i]; ans.pb(i); flag[i] = 1; kiri[x].pop(); int xx = kanan[x].front(); ans.pb(xx); flag[xx] = 1; kanan[x].pop(); } else { int x = s[i]; ans.pb(i); flag[i] = 1; kanan[x].pop(); int xx = kiri[x].front(); ans.pb(xx); flag[xx] = 1; kiri[x].pop(); } } } for (int i = 0; i < n; i += 2) { if (s[ans[i]] > 0) swap(ans[i], ans[i + 1]); } for (int i = 0; i < n; i++) { int cnt = tmp.order_of_key(ans[i]); cnt = i - cnt; ans2 += (ans[i] + cnt - i); tmp.insert(ans[i]); } return ans2; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:27:17: error: 'kiri' was not declared in this scope
   if (s[i] < 0) kiri[-s[i]].push(i);
                 ^~~~
shoes.cpp:27:17: note: suggested alternative: 'kill'
   if (s[i] < 0) kiri[-s[i]].push(i);
                 ^~~~
                 kill
shoes.cpp:28:8: error: 'kanan' was not declared in this scope
   else kanan[s[i]].push(i);
        ^~~~~
shoes.cpp:28:8: note: suggested alternative: '__nan'
   else kanan[s[i]].push(i);
        ^~~~~
        __nan
shoes.cpp:36:5: error: 'kiri' was not declared in this scope
     kiri[x].pop();
     ^~~~
shoes.cpp:36:5: note: suggested alternative: 'kill'
     kiri[x].pop();
     ^~~~
     kill
shoes.cpp:37:14: error: 'kanan' was not declared in this scope
     int xx = kanan[x].front();
              ^~~~~
shoes.cpp:37:14: note: suggested alternative: '__nan'
     int xx = kanan[x].front();
              ^~~~~
              __nan
shoes.cpp:45:5: error: 'kanan' was not declared in this scope
     kanan[x].pop();
     ^~~~~
shoes.cpp:45:5: note: suggested alternative: '__nan'
     kanan[x].pop();
     ^~~~~
     __nan
shoes.cpp:46:14: error: 'kiri' was not declared in this scope
     int xx = kiri[x].front();
              ^~~~
shoes.cpp:46:14: note: suggested alternative: 'kill'
     int xx = kiri[x].front();
              ^~~~
              kill