Submission #559343

#TimeUsernameProblemLanguageResultExecution timeMemory
559343LastRoninArranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; const ll N = 2e5; ll n; vector<ll> st ex[N]; long long count_swaps(vector<int> s) { n = s.size(); ll pos = 0; for(auto u : s) { if(u < 0) { st.pb(pos++); } else { ex[u].pb(pos++); } } for(int j = 1; j <= n; j++) { reverse(ex[j].begin(), ex[j].end()); } ll ans = 0; for(int j = 0; j < n; j += 2) { ll z = -1; for(int i = j; i < n; i++) { if(s[i] < 0) { z = i; break; } } for(int i = z; i > j; i--) swap(s[i], s[i - 1]), ans++; z = -1; for(int i = j + 1; i < n; i++) { if(s[i] == -s[j]) { z = i; } } for(int i = z; i > j + 1; i--) swap(s[i], s[i - 1]), ans++; } return ans; }

Compilation message (stderr)

shoes.cpp:5:7: error: 'll' does not name a type
    5 | const ll N = 2e5;
      |       ^~
shoes.cpp:7:1: error: 'll' does not name a type
    7 | ll n;
      | ^~
shoes.cpp:8:8: error: 'll' was not declared in this scope
    8 | vector<ll> st ex[N];
      |        ^~
shoes.cpp:8:10: error: template argument 1 is invalid
    8 | vector<ll> st ex[N];
      |          ^
shoes.cpp:8:10: error: template argument 2 is invalid
shoes.cpp:8:15: error: expected initializer before 'ex'
    8 | vector<ll> st ex[N];
      |               ^~
shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:11:2: error: 'n' was not declared in this scope
   11 |  n = s.size();
      |  ^
shoes.cpp:12:2: error: 'll' was not declared in this scope
   12 |  ll pos = 0;
      |  ^~
shoes.cpp:15:4: error: 'st' was not declared in this scope; did you mean 's'?
   15 |    st.pb(pos++);
      |    ^~
      |    s
shoes.cpp:15:10: error: 'pos' was not declared in this scope; did you mean 'pow'?
   15 |    st.pb(pos++);
      |          ^~~
      |          pow
shoes.cpp:18:4: error: 'ex' was not declared in this scope; did you mean 'exp'?
   18 |    ex[u].pb(pos++);
      |    ^~
      |    exp
shoes.cpp:18:13: error: 'pos' was not declared in this scope; did you mean 'pow'?
   18 |    ex[u].pb(pos++);
      |             ^~~
      |             pow
shoes.cpp:22:11: error: 'ex' was not declared in this scope; did you mean 'exp'?
   22 |   reverse(ex[j].begin(), ex[j].end());
      |           ^~
      |           exp
shoes.cpp:24:4: error: expected ';' before 'ans'
   24 |  ll ans = 0;
      |    ^~~~
      |    ;
shoes.cpp:26:5: error: expected ';' before 'z'
   26 |   ll z = -1;
      |     ^~
      |     ;
shoes.cpp:29:5: error: 'z' was not declared in this scope
   29 |     z = i;
      |     ^
shoes.cpp:33:15: error: 'z' was not declared in this scope
   33 |   for(int i = z; i > j; i--)
      |               ^
shoes.cpp:34:26: error: 'ans' was not declared in this scope; did you mean 'abs'?
   34 |    swap(s[i], s[i - 1]), ans++;
      |                          ^~~
      |                          abs
shoes.cpp:35:3: error: 'z' was not declared in this scope
   35 |   z = -1;
      |   ^
shoes.cpp:42:26: error: 'ans' was not declared in this scope; did you mean 'abs'?
   42 |    swap(s[i], s[i - 1]), ans++;
      |                          ^~~
      |                          abs
shoes.cpp:44:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   44 |  return ans;
      |         ^~~
      |         abs