Submission #531936

#TimeUsernameProblemLanguageResultExecution timeMemory
531936andecaandeciArranging Shoes (IOI19_shoes)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#define REP(v, i, j) for (int v = i; v < j; v++)
#define FORI(v) for (auto i : v)
#define FORJ(v) for (auto j : v)

#define OUT(v, a)     FORI(v)           cout << i << a;
#define OUTS(v, a, b)          cout << v.size() << a;     OUT(v, b)
#define in(a, n)     REP(i, 0, n)     cin >> a[i];

#define SORT(v) sort(begin(v), end(v))
#define REV(v) reverse(begin(v), end(v))

#define pb push_back
#define fi first
#define se second

#define detachIO                          ios_base::sync_with_stdio(false);     cin.tie(0);                           cout.tie(0);

using namespace std;

typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<pii, pii> piiii;

int inv(vector<int> v)
{
    if (v.size() < 2)
        return 0;

    int m = 1;
    for (int i = 1; i < v.size(); i++)
    {
        if (v[i] < v[m])
            m = i;
    }

    int ans = 0;
    if (v[m] < v[0])
    {
        swap(v[0], v[m]);
        ans++;
    }

    reverse(v.begin(), v.end());
    v.pop_back();
    reverse(v.begin(), v.end());

    ans += inv(v);
    return ans;
}

long long count_swaps(int S[])
{
    if ((sizeof(S) / sizeof(S[0])) == 1)
        if (S[0] < 0)
            return 0;
        else
            return 1;
}

Compilation message (stderr)

shoes.cpp: In function 'int inv(std::vector<int>)':
shoes.cpp:31:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for (int i = 1; i < v.size(); i++)
      |                     ~~^~~~~~~~~~
shoes.cpp: In function 'long long int count_swaps(int*)':
shoes.cpp:54:17: warning: 'sizeof' on array function parameter 'S' will return size of 'int*' [-Wsizeof-array-argument]
   54 |     if ((sizeof(S) / sizeof(S[0])) == 1)
      |                ~^~
shoes.cpp:52:27: note: declared here
   52 | long long count_swaps(int S[])
      |                       ~~~~^~~
shoes.cpp:54:8: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
   54 |     if ((sizeof(S) / sizeof(S[0])) == 1)
      |        ^
shoes.cpp:59:1: warning: control reaches end of non-void function [-Wreturn-type]
   59 | }
      | ^
/usr/bin/ld: /tmp/cc6WTjH4.o: in function `main':
grader.cpp:(.text.startup+0x2a8): undefined reference to `count_swaps(std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status