제출 #1295973

#제출 시각아이디문제언어결과실행 시간메모리
1295973turbatArranging Shoes (IOI19_shoes)C++20
컴파일 에러
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;
}

컴파일 시 표준 에러 (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;