답안 #1052241

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1052241 2024-08-10T12:40:02 Z Sacharlemagne Monster Game (JOI21_monster) C++17
컴파일 오류
0 ms 0 KB
#include "monster.h"
using namespace std;
namespace {

bool example_variable;

}  // namespace

vector<int> Solve(int N) {
    vector<int> v(N), ans(N);
    for (int i = 0; i<N; ++i) {
        ans[i] = i;
        for (int j = i+1; j<N; ++j) {
            ++v[Query(i,j) ? i : j];
        }
    }
    sort(ans.begin(), ans.end(), [&](int a, int b) {return v[a] < v[b];});
    if (!Query(ans[0], ans[1])) swap(ans[0], ans[1]);
    if (!Query(ans[N-2], ans[N-1]))
        swap(ans[N-2], ans[N-1]);

}

Compilation message

monster.cpp: In function 'std::vector<int> Solve(int)':
monster.cpp:17:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   17 |     sort(ans.begin(), ans.end(), [&](int a, int b) {return v[a] < v[b];});
      |     ^~~~
      |     short
monster.cpp:22:1: warning: no return statement in function returning non-void [-Wreturn-type]
   22 | }
      | ^
monster.cpp: At global scope:
monster.cpp:5:6: warning: '{anonymous}::example_variable' defined but not used [-Wunused-variable]
    5 | bool example_variable;
      |      ^~~~~~~~~~~~~~~~