Submission #1295973

#TimeUsernameProblemLanguageResultExecution timeMemory
1295973turbatArranging Shoes (IOI19_shoes)C++20
Compilation error
0 ms0 KiB
#include "shoes.h"
using namespace std;

long long count_swaps(vector<int> s) {
    int n = s.size(), ans = 0;
    printf("hahahaha");
    for (int i = 0; i < n; i += 2) {
        int pos = i;
        for (int j = i; j < n; j++)
            if (s[j] == -s[i]) {
                pos = j;
                break;
            }
        for (int j = pos; j > i + 1; j--) {
            if (s[j] == -s[i]) {
                swap(s[j], s[j - 1]);
                ans++;
            }
        }
        if (s[i] > 0) {
            swap(s[i], s[i + 1]);
            ans++;
        }
    }
    return ans;
}

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:6:5: error: 'printf' was not declared in this scope
    6 |     printf("hahahaha");
      |     ^~~~~~
shoes.cpp:2:1: note: 'printf' is defined in header '<cstdio>'; did you forget to '#include <cstdio>'?
    1 | #include "shoes.h"
  +++ |+#include <cstdio>
    2 | using namespace std;