Submission #232400

# Submission time Handle Problem Language Result Execution time Memory
232400 2020-05-16T23:45:50 Z jam_xd_ Arranging Shoes (IOI19_shoes) C++17
10 / 100
4 ms 432 KB
#include "shoes.h"
#include "bits/stdc++.h"

using namespace std;

long long count_swaps(std::vector<int> s) {

/*  10 puntitios :D, ez

	if(s[0] < 0 and s[1] > 0)return 0;
	if(s[0] > 1 and s[1] < 0)return 1;
*/


	int contador=0;
	int swaps = 0;

	int aux;

	for(int i=0;i<s.size();i++){
		if(s[i] > 0 && i%2 == 0){
			for(int j=i;j<s.size();j++){
				contador++;
				if(s[j] > 0 && i%2==0){
					swaps = swaps + contador;
					aux = s[i];
					s[i] = s[j];
					s[j] = aux;
					contador = 0;
					break;
				}
			}
		}

		if(s[i] < 0 && i%2 != 0){
			for(int k=i;k<s.size();k++){
				contador++;
				if(s[k] > 0 && i%2==0){
					swaps = swaps + contador;
					aux = s[i];
					s[i] = s[k];
					s[k] = aux;
					contador = 0;
					break;
				}
			}
		}
	}



	return swaps;
}

Compilation message

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:20:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<s.size();i++){
              ~^~~~~~~~~
shoes.cpp:22:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int j=i;j<s.size();j++){
                ~^~~~~~~~~
shoes.cpp:36:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int k=i;k<s.size();k++){
                ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Incorrect 4 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Incorrect 4 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB Output is correct
2 Incorrect 4 ms 432 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Incorrect 4 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Incorrect 4 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -