Submission #398593

# Submission time Handle Problem Language Result Execution time Memory
398593 2021-05-04T15:12:44 Z richyrich Arranging Shoes (IOI19_shoes) C++17
10 / 100
15 ms 19100 KB
```#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD = 1e9+7;
const ll N = 2e5+10;
const ll inf = 1e9+100;
const double eps = 1;
int n, a[N];
set<int> L[N], R[N];
ll ans;
bool used[N];
long long count_swaps(std::vector<int> s) {
/*for(int c : s) printf("%d ", c);
printf("\n");*/
ans = 0;
n = s.size();
for(int i = 1;i <= n;i++) {
a[i] = s[i-1];
if(a[i] < 0) L[-a[i]].insert(i);
else R[a[i]].insert(i);
}
/*for(int i = 1; i <= 2; i++) {
printf("left %d:", i);
for(int c : L[i]) printf("%d ", c);
printf("\n");
}
for(int i = 1; i <= 2; i++) {
printf("right %d:", i);
for(int c : R[i]) printf("%d ", c);
printf("\n");
}*/
for(int i = 1; i <= n; i++){
if(used[i]) continue;
int pos;
if(a[i] < 0) {
pos = *R[-a[i]].begin();
L[-a[i]].erase(i);
R[-a[i]].erase(pos);
ans += pos - i - 1;
used[pos] = used[i] = 1;
}
else {
pos = *L[a[i]].begin();
R[a[i]].erase(i);
L[a[i]].erase(pos);
ans += pos - i;
used[pos] = used[i] = 1;
}
}
return ans;
}```

# Verdict Execution time Memory Grader output
1 Correct 11 ms 19020 KB Output is correct
2 Correct 11 ms 19020 KB Output is correct

# Verdict Execution time Memory Grader output
1 Correct 11 ms 19020 KB Output is correct
2 Correct 11 ms 19020 KB Output is correct
3 Correct 11 ms 19100 KB Output is correct
4 Correct 15 ms 19028 KB Output is correct
5 Correct 12 ms 19040 KB Output is correct
6 Correct 12 ms 19020 KB Output is correct
7 Incorrect 12 ms 19020 KB Output isn't correct
8 Halted 0 ms 0 KB -

# Verdict Execution time Memory Grader output
1 Correct 11 ms 19020 KB Output is correct
2 Correct 11 ms 19020 KB Output is correct
3 Incorrect 10 ms 19024 KB Output isn't correct
4 Halted 0 ms 0 KB -

# Verdict Execution time Memory Grader output
1 Correct 10 ms 19020 KB Output is correct
2 Incorrect 10 ms 19068 KB Output isn't correct
3 Halted 0 ms 0 KB -

# Verdict Execution time Memory Grader output
1 Correct 11 ms 19020 KB Output is correct
2 Correct 11 ms 19020 KB Output is correct
3 Correct 11 ms 19100 KB Output is correct
4 Correct 15 ms 19028 KB Output is correct
5 Correct 12 ms 19040 KB Output is correct
6 Correct 12 ms 19020 KB Output is correct
7 Incorrect 12 ms 19020 KB Output isn't correct
8 Halted 0 ms 0 KB -