# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
771250 | teamariaa | Arranging Shoes (IOI19_shoes) | C++17 | 1 ms | 304 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 <bits/stdc++.h>
#include "shoes.h"
using namespace std;
long long count_swaps(vector<int> s)
{
long long n = s.size() / 2;
if(n == 1)
if(s[0] < s[1])
return 0;
else
return 1;
bool ok = 0;
for(int i = 1; i < s.size() && !ok; i ++)
if(abs(s[i]) != abs(s[i - 1]))
ok = 1;
if(!ok)
{
int pos = 0;
long long ans = 0;
for(int i = 0; i < s.size(); i ++)
if(s[i] < 0)
{
ans += i - pos;
pos += 2;
}
return ans;
}
return n * (n - 1) / 2;
}
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... |