Submission #1305499

#TimeUsernameProblemLanguageResultExecution timeMemory
1305499ayazArranging Shoes (IOI19_shoes)C++20
Compilation error
0 ms0 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; #define isz(x) (int)x.size() long long count_swaps(std::vector<int> s) { vector<int> a = s; int n = isz(a); if (n == 2) { return (a[0] > 0); } int ans = 0; for (int i = 0; i < n; i++) { int d = 1e9; for (int j = n - 1; j >= 0; j--) { if (a[i] + a[j] == 0 && abs(d - i) >= abs(j - i)) { d = j; } } if (d == i + 1 || d == i - 1) continue; int v = a[d]; a.erase(a.begin() + d); if (d < i) a.insert(a.begin() i, v); else a.insert(a.begin() + 1 + i, v); ans += (d > i ? d - (i + 1) : (i - 1) - d); // for( auto j : a) cout << j << ' '; // cout << '\n'; } for (int i = 0; i < n; i += 2) { ans += (a[i] > 0); } return ans; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:24:25: error: expected ')' before 'i'
   24 |       a.insert(a.begin() i, v);
      |               ~         ^~
      |                         )