Submission #143940

#TimeUsernameProblemLanguageResultExecution timeMemory
143940NucleistArranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "shoes.h" 
using namespace std; 
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define pb push_back
struct greateri
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};
ll count_swaps(vector<ll>S)
{
  //flash;
  ll ans=0;
  ll index=0;
  for (ll i = 0; i < S.size(); i+=2)
  {
    for (ll j = i; j < S.size(); ++j)
    {
      if(S[j]<0)
      {
        //debugs(j,i);
        ll newi=j;
        while(S[i]>0)
        {
          ll k = S[newi-1];
          S[newi-1]=S[newi];
          S[newi]=k;
          newi--;
          ans++;
        }
        break;
      }
    }
    for (ll j = i+1; j < S.size(); ++j)
    {
      if(S[j]==(-S[i]))
      {
        ll nexi=j;
        while(S[i+1]!=(-S[i]))
        {
          ll k = S[nexi-1];
          S[nexi-1]=S[nexi];
          S[nexi]=k;
          nexi--;
          ans++;
        }
        break;  
      }
    }
  }
  return ans;
}
//code the AC sol !
// BS/queue/map

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<long long int>)':
shoes.cpp:22:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (ll i = 0; i < S.size(); i+=2)
                  ~~^~~~~~~~~~
shoes.cpp:24:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (ll j = i; j < S.size(); ++j)
                    ~~^~~~~~~~~~
shoes.cpp:41:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (ll j = i+1; j < S.size(); ++j)
                      ~~^~~~~~~~~~
shoes.cpp:21:6: warning: unused variable 'index' [-Wunused-variable]
   ll index=0;
      ^~~~~
/tmp/ccRe08E6.o: In function `main':
grader.cpp:(.text.startup+0x272): undefined reference to `count_swaps(std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status