Submission #297236

#TimeUsernameProblemLanguageResultExecution timeMemory
297236A02Arranging Shoes (IOI19_shoes)C++14
50 / 100
1063 ms5344 KiB
#include <bits/stdc++.h>
#include "shoes.h"

using namespace std;

long long count_swaps(vector<int> s) {

	int N = s.size();

    long long total = 0;

    while(s.size()){

        int first = s[0];
        if (first > 0){
            total++;
        }

        vector<int> s1;

        bool found = false;
        for (int i = 1; i < s.size(); i++){
            if (!found && s[i] + s[0] == 0){
                found = true;
                total += i - 1;
            } else {
                s1.push_back(s[i]);
            }
        }

        s = s1;

    }

	return total;
}

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:22:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |         for (int i = 1; i < s.size(); i++){
      |                         ~~^~~~~~~~~~
shoes.cpp:8:6: warning: unused variable 'N' [-Wunused-variable]
    8 |  int N = s.size();
      |      ^
#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...