Submission #722867

#TimeUsernameProblemLanguageResultExecution timeMemory
722867GrandTiger1729Arranging Shoes (IOI19_shoes)C++17
50 / 100
1095 ms2652 KiB
#include "shoes.h"
#include <bits/stdc++.h>
using namespace std;

long long count_swaps(vector<int> s){
	auto a = s;
    int N = a.size(), n = N / 2;
    long long cnt = 0;
    for (int i = 0; i < N; i += 2){
        int j = i;
        j = i + 1;
        while (j < N && a[j] != -a[i]) j++;
        while (j > i + 1){
            swap(a[j], a[j - 1]);
            j--;
            cnt++;
        }
        if (a[i] > 0){
            swap(a[i], a[i + 1]);
            cnt++;
        }
    }
    return cnt;
}

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:7:23: warning: unused variable 'n' [-Wunused-variable]
    7 |     int N = a.size(), n = N / 2;
      |                       ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...