Submission #722852

#TimeUsernameProblemLanguageResultExecution timeMemory
722852GrandTiger1729Arranging Shoes (IOI19_shoes)C++17
10 / 100
1089 ms2644 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;
        while (j < N && a[j] > 0) j++;
        while (j > i){
            swap(a[j], a[j - 1]);
            j--;
            cnt++;
        }
        j = i + 1;
        while (j < N && a[j] != -a[i]) j++;
        while (j > i + 1){
            swap(a[j], a[j - 1]);
            j--;
            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...