Submission #1061113

# Submission time Handle Problem Language Result Execution time Memory
1061113 2024-08-16T06:26:19 Z 12345678 Monster Game (JOI21_monster) C++17
52 / 100
138 ms 5664 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;

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]) 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]);
                else tmp.push_back(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++)
    {
        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]]++;
            }
        }
    }
    //for (int i=0; i<n; i++) cout<<i<<' '<<cnt[i]<<'\n';
    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;
    //for (int i=0; i<n; i++) cout<<i<<' '<<res[i]<<'\n';
    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:28:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |             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 0 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 596 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 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 476 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 16 ms 1232 KB Output is correct
17 Correct 14 ms 1488 KB Output is correct
18 Correct 14 ms 1240 KB Output is correct
19 Correct 18 ms 1112 KB Output is correct
20 Correct 14 ms 1240 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 0 ms 344 KB Output is correct
26 Correct 16 ms 1244 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 356 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 14 ms 1244 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 0 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 596 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 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 476 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 16 ms 1232 KB Output is correct
17 Correct 14 ms 1488 KB Output is correct
18 Correct 14 ms 1240 KB Output is correct
19 Correct 18 ms 1112 KB Output is correct
20 Correct 14 ms 1240 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 0 ms 344 KB Output is correct
26 Correct 16 ms 1244 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 356 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 14 ms 1244 KB Output is correct
33 Correct 104 ms 4376 KB Output is correct
34 Correct 100 ms 4356 KB Output is correct
35 Correct 84 ms 4432 KB Output is correct
36 Correct 119 ms 4440 KB Output is correct
37 Correct 98 ms 4364 KB Output is correct
38 Correct 102 ms 4372 KB Output is correct
39 Correct 129 ms 4432 KB Output is correct
40 Correct 125 ms 4368 KB Output is correct
41 Correct 114 ms 4440 KB Output is correct
42 Correct 120 ms 4184 KB Output is correct
43 Correct 90 ms 4432 KB Output is correct
44 Correct 75 ms 4368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 105 ms 4440 KB Partially correct
2 Partially correct 136 ms 4384 KB Partially correct
3 Partially correct 117 ms 4368 KB Partially correct
4 Partially correct 111 ms 4368 KB Partially correct
5 Partially correct 112 ms 5664 KB Partially correct
6 Partially correct 106 ms 4368 KB Partially correct
7 Partially correct 102 ms 4380 KB Partially correct
8 Partially correct 120 ms 4496 KB Partially correct
9 Partially correct 137 ms 4432 KB Partially correct
10 Partially correct 113 ms 4372 KB Partially correct
11 Partially correct 138 ms 4372 KB Partially correct
12 Partially correct 125 ms 4372 KB Partially correct
13 Partially correct 116 ms 4376 KB Partially correct
14 Partially correct 102 ms 4372 KB Partially correct
15 Partially correct 108 ms 4440 KB Partially correct
16 Partially correct 78 ms 4388 KB Partially correct
17 Partially correct 128 ms 4376 KB Partially correct
18 Partially correct 61 ms 4432 KB Partially correct