Submission #1061127

# Submission time Handle Problem Language Result Execution time Memory
1061127 2024-08-16T06:29:58 Z 12345678 Monster Game (JOI21_monster) C++17
58 / 100
122 ms 4952 KB
#include "monster.h"
#include <bits/stdc++.h>

using namespace std;

const int nx=1005;

int n, dp[nx][nx], cnt[nx], used[nx], pw[nx], x, y;
set<int> s[nx];

int query(int a, int b)
{
    if (dp[a][b]) return dp[a][b]-1;
    dp[a][b]=Query(a, b);
    dp[b][a]=!dp[a][b];
    dp[a][b]++, dp[b][a]++;
    return dp[a][b]-1;
}

std::vector<int> Solve(int N) {
    n=N;
    for (int t=0; t<N; t++)
    {
        vector<int> v;
        for (int i=0; i<N; i++) if (!used[i]&&s[i].empty()) v.push_back(i);
        while (v.size()>1)
        {
            vector<int> tmp;
            for (int i=0; i+1<v.size(); i+=2)
            {
                if (!query(v[i], v[i+1])) tmp.push_back(v[i]), s[v[i+1]].insert(v[i]);
                else tmp.push_back(v[i+1]), s[v[i]].insert(v[i+1]);
            }
            if (v.size()%2) tmp.push_back(v.back());
            v=tmp;
        }
        pw[t]=v[0];
        used[v[0]]=1;
        for (int i=0; i<N; i++) if (s[i].find(v[0])!=s[i].end()) s[i].erase(v[0]);
    }
    for (int i=0; i<n; i++)
    {
        for (int j=0; j<n; j++)
        {
            if (i==j) continue;
            if (i<j-10) cnt[pw[j]]++;
            else if (i>j+10) cnt[pw[i]]++;
            else
            {
                if (query(pw[i], pw[j])) cnt[pw[i]]++;
                else cnt[pw[j]]++;
            }
        }
    }
    vector<pair<int ,int>> v;
    for (int i=0; i<n; i++) v.push_back({cnt[i], i});
    sort(v.begin(), v.end());
    vector<int> res(n), ans(n);
    for (int i=0; i<n; i++) res[i]=v[i].second;
    if (!query(res[0], res[1])) swap(res[0], res[1]);
    if (!query(res[n-2], res[n-1])) swap(res[n-2], res[n-1]);
    for (int i=0; i<n; i++) ans[res[i]]=i;
    return ans;
}

Compilation message

monster.cpp: In function 'std::vector<int> Solve(int)':
monster.cpp:29:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |             for (int i=0; i+1<v.size(); i+=2)
      |                           ~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 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 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 11 ms 2648 KB Output is correct
17 Correct 12 ms 2648 KB Output is correct
18 Correct 15 ms 2672 KB Output is correct
19 Correct 13 ms 2648 KB Output is correct
20 Correct 10 ms 2904 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 1 ms 344 KB Output is correct
25 Correct 0 ms 344 KB Output is correct
26 Correct 9 ms 2648 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 1 ms 348 KB Output is correct
32 Correct 9 ms 2648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 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 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 11 ms 2648 KB Output is correct
17 Correct 12 ms 2648 KB Output is correct
18 Correct 15 ms 2672 KB Output is correct
19 Correct 13 ms 2648 KB Output is correct
20 Correct 10 ms 2904 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 1 ms 344 KB Output is correct
25 Correct 0 ms 344 KB Output is correct
26 Correct 9 ms 2648 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 1 ms 348 KB Output is correct
32 Correct 9 ms 2648 KB Output is correct
33 Correct 122 ms 4444 KB Output is correct
34 Correct 103 ms 4440 KB Output is correct
35 Correct 101 ms 4440 KB Output is correct
36 Correct 110 ms 4440 KB Output is correct
37 Correct 112 ms 4484 KB Output is correct
38 Correct 95 ms 4440 KB Output is correct
39 Correct 107 ms 4440 KB Output is correct
40 Correct 114 ms 4440 KB Output is correct
41 Correct 96 ms 4440 KB Output is correct
42 Correct 97 ms 4440 KB Output is correct
43 Correct 51 ms 4440 KB Output is correct
44 Correct 53 ms 4440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 111 ms 4452 KB Partially correct
2 Partially correct 85 ms 4320 KB Partially correct
3 Partially correct 93 ms 4476 KB Partially correct
4 Partially correct 91 ms 4440 KB Partially correct
5 Partially correct 90 ms 4584 KB Partially correct
6 Partially correct 60 ms 4464 KB Partially correct
7 Partially correct 57 ms 4456 KB Partially correct
8 Partially correct 75 ms 4440 KB Partially correct
9 Partially correct 77 ms 4448 KB Partially correct
10 Partially correct 85 ms 4476 KB Partially correct
11 Partially correct 97 ms 4352 KB Partially correct
12 Partially correct 84 ms 4952 KB Partially correct
13 Partially correct 86 ms 4704 KB Partially correct
14 Partially correct 87 ms 4480 KB Partially correct
15 Partially correct 45 ms 4464 KB Partially correct
16 Partially correct 59 ms 4472 KB Partially correct
17 Partially correct 102 ms 4452 KB Partially correct
18 Partially correct 54 ms 4440 KB Partially correct