Submission #662489

# Submission time Handle Problem Language Result Execution time Memory
662489 2022-11-26T10:07:51 Z LittleCube Monster Game (JOI21_monster) C++17
25 / 100
100 ms 428 KB
#include "monster.h"
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define piii tuple<int, int, int>
using namespace std;

vector<int> merge(vector<int> v)
{
    int n = v.size();
    if (n == 1)
        return v;

    vector<int> l, r;
    for (int i = 0; i < n; i++)
        if (i < n / 2)
            l.push_back(v[i]);
        else
            r.push_back(v[i]);

    v.clear();
    l = merge(l);
    r = merge(r);
    int ldx = 0, rdx = 0;
    while (ldx < l.size() || rdx < r.size())
    {
        if (ldx >= l.size())
            v.push_back(r[rdx++]);
        else if (rdx >= r.size())
            v.push_back(l[ldx++]);
        else if (Query(l[ldx], r[rdx]))
            v.push_back(r[rdx++]);
        else
            v.push_back(l[ldx++]);
    }
    return v;
}

vector<int> Solve(int N)
{
    vector<int> v;
    for (int i = 0; i < N; i++)
        v.push_back(i);
    v = merge(v);
    for (int i = 0; i < N; i++)
        cerr << v[i] << " \n"[i == N - 1];
    int start = 0;
    if (Query(v[0], v[1]))
        start = 1;
    else if (Query(v[2], v[0]))
    {
        if (Query(v[3], v[1]))
            start = 2;
        else
            start = 1;
    }
    else if (Query(v[3], v[1]))
        for (int j = 3; j < N; j++)
        {
            if (Query(v[2], v[j]))
            {
                start = 2;
                break;
            }
            else if (Query(v[0], v[j]))
            {
                start = 3;
                break;
            }
            else if (Query(v[1], v[j]))
            {
                start = 1;
                break;
            }
        }
    else
    {
        for (int i = 2; i < N - 2; i++)
            if (Query(v[i], v[i + 2]))
                start = i + 2;
    }
    cerr << start << '\n';
    reverse(v.begin(), v.begin() + start);
    for (int i = start; i < N;)
    {
        int j = i;
        while (Query(v[j], v[i - 1]))
            j++;
        j++;
        reverse(v.begin() + i, v.begin() + j);
        i = j;
    }
    for (int i = 0; i < N; i++)
        cerr << v[i] << " \n"[i == N - 1];
    vector<int> T(N);
    for (int i = 0; i < N; i++)
        T[v[i]] = i;
    return T;
}

Compilation message

monster.cpp: In function 'std::vector<int> merge(std::vector<int>)':
monster.cpp:26:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     while (ldx < l.size() || rdx < r.size())
      |            ~~~~^~~~~~~~~~
monster.cpp:26:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     while (ldx < l.size() || rdx < r.size())
      |                              ~~~~^~~~~~~~~~
monster.cpp:28:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |         if (ldx >= l.size())
      |             ~~~~^~~~~~~~~~~
monster.cpp:30:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |         else if (rdx >= r.size())
      |                  ~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 1 ms 208 KB Output is correct
10 Correct 1 ms 208 KB Output is correct
11 Correct 1 ms 208 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 1 ms 208 KB Output is correct
16 Correct 14 ms 208 KB Output is correct
17 Correct 12 ms 208 KB Output is correct
18 Correct 11 ms 208 KB Output is correct
19 Correct 15 ms 208 KB Output is correct
20 Correct 12 ms 300 KB Output is correct
21 Correct 0 ms 208 KB Output is correct
22 Correct 1 ms 208 KB Output is correct
23 Correct 0 ms 208 KB Output is correct
24 Correct 1 ms 208 KB Output is correct
25 Correct 1 ms 208 KB Output is correct
26 Correct 9 ms 308 KB Output is correct
27 Correct 1 ms 208 KB Output is correct
28 Correct 1 ms 300 KB Output is correct
29 Correct 1 ms 208 KB Output is correct
30 Correct 1 ms 208 KB Output is correct
31 Correct 1 ms 208 KB Output is correct
32 Correct 10 ms 300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 1 ms 208 KB Output is correct
10 Correct 1 ms 208 KB Output is correct
11 Correct 1 ms 208 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 1 ms 208 KB Output is correct
16 Correct 14 ms 208 KB Output is correct
17 Correct 12 ms 208 KB Output is correct
18 Correct 11 ms 208 KB Output is correct
19 Correct 15 ms 208 KB Output is correct
20 Correct 12 ms 300 KB Output is correct
21 Correct 0 ms 208 KB Output is correct
22 Correct 1 ms 208 KB Output is correct
23 Correct 0 ms 208 KB Output is correct
24 Correct 1 ms 208 KB Output is correct
25 Correct 1 ms 208 KB Output is correct
26 Correct 9 ms 308 KB Output is correct
27 Correct 1 ms 208 KB Output is correct
28 Correct 1 ms 300 KB Output is correct
29 Correct 1 ms 208 KB Output is correct
30 Correct 1 ms 208 KB Output is correct
31 Correct 1 ms 208 KB Output is correct
32 Correct 10 ms 300 KB Output is correct
33 Correct 78 ms 332 KB Output is correct
34 Correct 48 ms 304 KB Output is correct
35 Correct 67 ms 324 KB Output is correct
36 Correct 94 ms 208 KB Output is correct
37 Correct 81 ms 304 KB Output is correct
38 Correct 78 ms 208 KB Output is correct
39 Correct 87 ms 208 KB Output is correct
40 Correct 88 ms 300 KB Output is correct
41 Correct 87 ms 300 KB Output is correct
42 Correct 81 ms 308 KB Output is correct
43 Correct 49 ms 304 KB Output is correct
44 Correct 49 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 73 ms 324 KB Output is correct
2 Correct 100 ms 312 KB Output is correct
3 Correct 76 ms 300 KB Output is correct
4 Correct 67 ms 312 KB Output is correct
5 Correct 76 ms 300 KB Output is correct
6 Correct 64 ms 208 KB Output is correct
7 Correct 68 ms 308 KB Output is correct
8 Correct 74 ms 308 KB Output is correct
9 Correct 87 ms 308 KB Output is correct
10 Correct 82 ms 332 KB Output is correct
11 Correct 80 ms 428 KB Output is correct
12 Correct 71 ms 312 KB Output is correct
13 Incorrect 80 ms 300 KB Wrong Answer [3]
14 Halted 0 ms 0 KB -