# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
298194 | arayi | Arranging Shoes (IOI19_shoes) | C++17 | 115 ms | 135032 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "shoes.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 30;
queue <int> a[N];
long long pat;
int v(int x)
{
if(x < 0) return -1;
else return 1;
}
long long count_swaps(std::vector<int> s) {
for (int i = 1; i <= s.size(); i++)
{
int x = abs(s[i - 1]);
if(a[x].empty() || v(s[i - 1]) == v(a[x].front()))
a[x].push(i * v(s[i - 1]));
else
{
pat += i - abs(a[x].front());
a[x].pop();
if(s[i - 1] > 0) pat--;
}
}
return pat;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |