Submission #1144481

#TimeUsernameProblemLanguageResultExecution timeMemory
1144481zhasynArranging Shoes (IOI19_shoes)C++20
Compilation error
0 ms0 KiB
#include "shoes.h" using namespace std; #define ll long long const ll N = 1e5 + 100; ll fen[N]; deque <ll> pos[N], neg[N]; void upd(int i, int delta){ for(; i < N; i |= (i + 1)){ fen[i] += delta; } } ll get(ll r){ ll res = 0; for(; r >= 0; r = (r &(r + 1)) - 1){ res += fen[r]; } return res; } long long count_swaps(std::vector<int> s) { ll ans = 0, last; for(int i = 0; i < (int)s.size(); i++){ if(vec[i] < 0) neg[-s[i]].pb(i); else pos[s[i]].pb(i); upd(i, 1); } for(int i = 0; i < n; i++){ if(was[i]) continue; if(s[i] < 0){ last = pos[-s[i]].front(); ans -= 2; } else{ last = neg[s[i]].front(); ans--; } pos[abs(s[i])].pop_front(); pos[abs(s[i])].pop_front(); ans += get(last); was[last] = true; upd(last, -1); upd(i, -1); } return ans; }

Compilation message (stderr)

shoes.cpp:6:1: error: 'deque' does not name a type
    6 | deque <ll> pos[N], neg[N];
      | ^~~~~
shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:22:20: error: 'vec' was not declared in this scope
   22 |                 if(vec[i] < 0) neg[-s[i]].pb(i);
      |                    ^~~
shoes.cpp:22:32: error: 'neg' was not declared in this scope
   22 |                 if(vec[i] < 0) neg[-s[i]].pb(i);
      |                                ^~~
shoes.cpp:23:22: error: 'pos' was not declared in this scope
   23 |                 else pos[s[i]].pb(i);
      |                      ^~~
shoes.cpp:27:28: error: 'n' was not declared in this scope
   27 |         for(int i = 0; i < n; i++){
      |                            ^
shoes.cpp:28:20: error: 'was' was not declared in this scope
   28 |                 if(was[i]) continue;
      |                    ^~~
shoes.cpp:30:32: error: 'pos' was not declared in this scope
   30 |                         last = pos[-s[i]].front();
      |                                ^~~
shoes.cpp:34:32: error: 'neg' was not declared in this scope
   34 |                         last = neg[s[i]].front();
      |                                ^~~
shoes.cpp:38:17: error: 'pos' was not declared in this scope
   38 |                 pos[abs(s[i])].pop_front();
      |                 ^~~
shoes.cpp:42:17: error: 'was' was not declared in this scope
   42 |                 was[last] = true;
      |                 ^~~