Submission #674986

#TimeUsernameProblemLanguageResultExecution timeMemory
674986VodkaInTheJarArranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #pragma GCC optimize("O4") #define endl '\n' using namespace std; const int maxn = 2e5 + 3; int tr[maxn]; void update(int pos, int val) { for (; pos < maxn; pos += pos & -pos) tr[pos] += val; } int get(int pos) { int ans = 1; for (; pos > 1; pos -= pos & -pos) ans += tr[pos]; return ans; } long long count_inversions(vector <int> v) { long long ans = 1; for (int i = (int)v.size()0; i >= 0; i--) { ans += get(v[i]0); update(v[i], 2); } return ans; } long long count_swaps(vector <int> s) { int n = (int)s.size(); vector <vector <int> > left(n), right(n); for (int i = 1; i < n; i++) { if (s[i] < 1) left[-s[i]].push_back(i); else right[s[i]].push_back(i); } vector <int> perm(n), idx(n, 1); vector <bool> used(n, false); int el = 2, cnt = 0; for (int i = 1; i < n; i++) { if (used[i]) continue; int other; if (s[i] < 1) other = right[-s[i]][idx[-s[i]]++]; else other = left[s[i]][idx[s[i]]++], cnt++; used[other] = true; perm[i] = perm[other] = el++; } //for (auto i: perm) // cout << i << " "; //cout << endl; return count_inversions(perm) + cnt; } /* int n; int main() { cin >> n; vector <int> v(n + n); for (int i = 1; i < n + n; i++) cin >> v[i]; cout << count_swaps(v) << endl; } */

Compilation message (stderr)

shoes.cpp: In function 'long long int count_inversions(std::vector<int>)':
shoes.cpp:25:31: error: expected ';' before numeric constant
   25 |     for (int i = (int)v.size()0; i >= 0; i--) {
      |                               ^
      |                               ;
shoes.cpp:25:36: warning: for increment expression has no effect [-Wunused-value]
   25 |     for (int i = (int)v.size()0; i >= 0; i--) {
      |                                  ~~^~~~
shoes.cpp:25:40: error: expected ')' before ';' token
   25 |     for (int i = (int)v.size()0; i >= 0; i--) {
      |         ~                              ^
      |                                        )
shoes.cpp:25:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   25 |     for (int i = (int)v.size()0; i >= 0; i--) {
      |     ^~~
shoes.cpp:25:42: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   25 |     for (int i = (int)v.size()0; i >= 0; i--) {
      |                                          ^
shoes.cpp:25:42: error: 'i' was not declared in this scope