Submission #895461

#TimeUsernameProblemLanguageResultExecution timeMemory
895461ozner77Arranging Shoes (IOI19_shoes)C++17
Compilation error
0 ms0 KiB
#include "shoes.h"
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <string>
using namespace std;
long long count_swaps(std::vector<int> s) {
	int a,b,c,d;
	long long swaps=0;
	a=s[0];
	b=s[0];
	for(int k=0;k<s.size();k+=2){
        a=s[k];
        b=s[k];
	for(int i=k;i<s.size();i++){
        if(s[i]<0){
            swaps++;
            s[k]=s[i];
            s[i]=a;
            c=s[k+1];
            d=s[k+1];
            for(int j=k+1;j<s.size();j++){
                if(s[j]+s[k]==0){
                    s[k+1]=s[j];
                    s[j]=c;
                    break;
                }else if(i>=k+2){
                    d=s[j];
                    s[j]=c;
                    c=d;
                }
            }
        break;
        }else if(i>=k+1){
            swaps++
            b=s[i];
            s[i]=a;
            a=b;
        }
}
	}
    return swaps;
}

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:12:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |  for(int k=0;k<s.size();k+=2){
      |              ~^~~~~~~~~
shoes.cpp:15:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |  for(int i=k;i<s.size();i++){
      |              ~^~~~~~~~~
shoes.cpp:22:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |             for(int j=k+1;j<s.size();j++){
      |                           ~^~~~~~~~~
shoes.cpp:35:20: error: expected ';' before 'b'
   35 |             swaps++
      |                    ^
      |                    ;
   36 |             b=s[i];
      |             ~