Submission #870753

#TimeUsernameProblemLanguageResultExecution timeMemory
870753tuannmArranging Shoes (IOI19_shoes)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #define ii pair<int, int> #define ll pair<long long, long long> #define fi first #define se second #define pb push_back using namespace std; const int mod[2] = {1000000007, 998244353}; const int N = 2e5 + 1; const string NAME = ""; const int lim = 2147483647; //const unsigned int lim = 4294967295; //const long long lim = 9223372036854775807; //const unsigned long long lim = 18446744073709551615; const int mset = 0x3f; const double pi = acos(-1); int n, a[N]; vector<int> q[2][N]; int perm[N]; long long tree[4 * N]; bool used[N]; void update(int s, int l, int r, int x, int y){ if(x < l || x > r) return; if(l == r){ tree[s] += y; return; } int mid = (l + r) / 2; update(2 * s, l, mid, x, y); update(2 * s + 1, mid + 1, r, x, y); tree[s] = tree[2 * s] + tree[2 * s + 1]; } long long get(int s, int l, int r, int u, int v){ if(l > v || r < u) return 0; if(l >= u && r <= v) return tree[s]; int mid = (l + r) / 2; return get(2 * s, l, mid, u, v) + get(2 * s + 1, mid + 1, r, u, v); } long long count_swaps(int []S){ n = S.size() / 2; for(int i = 0; i < 2 * n; ++i){ if(a[i] > 0) q[1][a[i]].pb(i); else q[0][-a[i]].pb(i); } for(int i = 1; i <= n; ++i){ reverse(q[0][i].begin(), q[0][i].end()); reverse(q[1][i].begin(), q[1][i].end()); } int cnt = 0; for(int i = 0; i < 2 * n; ++i){ if(used[i]) continue; if(a[i] > 0){ int t0 = q[0][a[i]].back(); int t1 = q[1][a[i]].back(); q[1][a[i]].pop_back(); q[0][a[i]].pop_back(); used[t0] = true; used[t1] = true; perm[t0] = ++cnt; perm[t1] = ++cnt; } else{ int t0 = q[0][-a[i]].back(); int t1 = q[1][-a[i]].back(); q[1][-a[i]].pop_back(); q[0][-a[i]].pop_back(); used[t0] = true; used[t1] = true; perm[t0] = ++cnt; perm[t1] = ++cnt; } } long long ans = 0; for(int i = 0; i < 2 * n; ++i){ ans += get(1, 1, 2 * n, perm[i] + 1, 2 * n); update(1, 1, 2 * n, perm[i], 1); } return ans; }

Compilation message (stderr)

shoes.cpp:45:29: error: expected ',' or '...' before 'S'
   45 | long long count_swaps(int []S){
      |                             ^
shoes.cpp: In function 'long long int count_swaps(int*)':
shoes.cpp:46:8: error: 'S' was not declared in this scope
   46 |    n = S.size() / 2;
      |        ^