답안 #1052320

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1052320 2024-08-10T13:20:30 Z Sacharlemagne Monster Game (JOI21_monster) C++17
25 / 100
55 ms 696 KB
#include "monster.h"
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
namespace {

bool example_variable;

}  // namespace
vi solveP(int l, int r) {
    if (l == r) return {l};
    vi lp = solveP(l,(l+r)/2), rp = solveP(1+(l+r)/2,r);
    vi ans;
    int p1 = 0, p2 = 0;
    while (p1 < lp.size() || p2 < rp.size()) {
        if (p1 < lp.size() && p2 < rp.size()) {
            if (!Query(lp[p1],rp[p2])) ans.push_back(rp[p2++]);
            else ans.push_back(lp[p1++]);
        }
        else if (p1 < lp.size()) ans.push_back(lp[p1++]);
        else ans.push_back(rp[p2++]);
    }
    return ans;
}
vector<int> badSolve(int N, vi ans) {
    map<int,int> v;
    for (int i = 0; i<N; ++i) {
        for (int j = i+1; j<N; ++j) {
            ++v[Query(ans[i],ans[j]) ? ans[i] : ans[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]);
    return ans;
}
vi Solve(int N) {
    vi v = solveP(0,N-1);
    reverse(v.begin(), v.end());
    int k = min(N, 6);
    vi partial(v.begin(), v.begin()+k);
    int zero = badSolve(k,partial)[0];
    int ind = find(v.begin(), v.end(), zero)-v.begin();
    reverse(v.begin(), v.begin()+ind+1);
    while (ind < N-1) {
        int i = ind+1;
        while (Query(v[i],v[ind])) ++i;
        reverse(v.begin()+ind+1,v.begin()+i+1);
        ind = i;
    }
    vi ret(N); for (int i = 0; i<N; ++i) ret[v[i]] = i;
    return ret;
}

Compilation message

monster.cpp: In function 'vi solveP(int, int)':
monster.cpp:15:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     while (p1 < lp.size() || p2 < rp.size()) {
      |            ~~~^~~~~~~~~~~
monster.cpp:15:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     while (p1 < lp.size() || p2 < rp.size()) {
      |                              ~~~^~~~~~~~~~~
monster.cpp:16:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |         if (p1 < lp.size() && p2 < rp.size()) {
      |             ~~~^~~~~~~~~~~
monster.cpp:16:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |         if (p1 < lp.size() && p2 < rp.size()) {
      |                               ~~~^~~~~~~~~~~
monster.cpp:20:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |         else if (p1 < lp.size()) ans.push_back(lp[p1++]);
      |                  ~~~^~~~~~~~~~~
monster.cpp: At global scope:
monster.cpp:7:6: warning: '{anonymous}::example_variable' defined but not used [-Wunused-variable]
    7 | bool example_variable;
      |      ^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 5 ms 440 KB Output is correct
17 Correct 6 ms 344 KB Output is correct
18 Correct 7 ms 344 KB Output is correct
19 Correct 5 ms 432 KB Output is correct
20 Correct 4 ms 344 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 0 ms 344 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 5 ms 432 KB Output is correct
27 Correct 0 ms 344 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
29 Correct 0 ms 344 KB Output is correct
30 Correct 0 ms 344 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 5 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 5 ms 440 KB Output is correct
17 Correct 6 ms 344 KB Output is correct
18 Correct 7 ms 344 KB Output is correct
19 Correct 5 ms 432 KB Output is correct
20 Correct 4 ms 344 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 0 ms 344 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 5 ms 432 KB Output is correct
27 Correct 0 ms 344 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
29 Correct 0 ms 344 KB Output is correct
30 Correct 0 ms 344 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 5 ms 344 KB Output is correct
33 Correct 37 ms 432 KB Output is correct
34 Correct 38 ms 600 KB Output is correct
35 Correct 45 ms 696 KB Output is correct
36 Correct 35 ms 344 KB Output is correct
37 Correct 31 ms 680 KB Output is correct
38 Correct 30 ms 344 KB Output is correct
39 Correct 34 ms 592 KB Output is correct
40 Correct 43 ms 592 KB Output is correct
41 Correct 35 ms 588 KB Output is correct
42 Correct 40 ms 600 KB Output is correct
43 Correct 20 ms 344 KB Output is correct
44 Correct 21 ms 432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 43 ms 596 KB Output is correct
2 Correct 43 ms 592 KB Output is correct
3 Incorrect 55 ms 436 KB Wrong Answer [4]
4 Halted 0 ms 0 KB -