Submission #489029

#TimeUsernameProblemLanguageResultExecution timeMemory
489029baibhavkumarArranging Shoes (IOI19_shoes)C++14
10 / 100
0 ms204 KiB
#include "shoes.h"
#include <bits/stdc++.h>
using namespace std;

long long count_swaps(std::vector<int> s) {
  int n = s.size() / 2;
  if (s.size() == 2) {
    if (s[0] > s[1]) {
      return 1;
    } else {
      return 0;
    }
  } else {
    int a = 0;
    for (int i = 0; i < s.size(); i++) {
      if (s[i] != -(s[i+1]) || s[i] > s[i+1]) {
        a++; 
      } 
    }
    return a*a;
  }

}

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:15:23: 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 = 0; i < s.size(); i++) {
      |                     ~~^~~~~~~~~~
shoes.cpp:6:7: warning: unused variable 'n' [-Wunused-variable]
    6 |   int n = s.size() / 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...