제출 #1361053

#제출 시각아이디문제언어결과실행 시간메모리
1361053unix49Rotating Lines (APIO25_rotate)C++20
컴파일 에러
0 ms0 KiB
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
void energy(int n, vector<int> v) {
    long long ans = 0;

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            int diff = abs(v[i] - v[j]);
            diff = min(diff, 50000 - diff);
            ans += diff;
        }
    }
    cout << ans << endl;
}

컴파일 시 표준 에러 (stderr) 메시지

rotate.cpp:5:20: error: 'vector' has not been declared
    5 | void energy(int n, vector<int> v) {
      |                    ^~~~~~
rotate.cpp:5:26: error: expected ',' or '...' before '<' token
    5 | void energy(int n, vector<int> v) {
      |                          ^
rotate.cpp: In function 'void energy(int, int)':
rotate.cpp:10:28: error: 'v' was not declared in this scope
   10 |             int diff = abs(v[i] - v[j]);
      |                            ^