답안 #876097

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
876097 2023-11-21T08:46:47 Z green_gold_dog Monster Game (JOI21_monster) C++17
10 / 100
149 ms 4520 KB
#include<bits/stdc++.h>
#include "monster.h"

using namespace std;

random_device rd;
mt19937 rnd(rd());

typedef int ll;

map<pair<ll, ll>, bool> m;

bool query(ll a, ll b) {
        return (m.find(make_pair(a, b)) != m.end() ? m[make_pair(a, b)] : (m[make_pair(a, b)] = !(m[make_pair(b, a)] = Query(b, a))));
}

void s(vector<ll>& all) {
        if (all.empty()) {
                return;
        }
        if (true) {
                vector<pair<ll, ll>> now;
                vector<vector<ll>> big(all.size()), sma(all.size());
                for (ll i = 0; i < all.size(); i++) {
                        ll cb = 0;
                        for (ll j = 0; j < all.size(); j++) {
                                if (i != j) {
                                        if (query(all[i], all[j])) {
                                                sma[i].push_back(j);
                                        } else {
                                                cb++;
                                                big[i].push_back(j);
                                        }
                                }
                        }
                        now.emplace_back(cb, i);
                }
                sort(now.rbegin(), now.rend());
                if (sma[now[1].second][0] == now[0].second) {
                        swap(now[0], now[1]);
                }
                if (big[now[now.size() - 2].second][0] == now.back().second) {
                        swap(now[now.size() - 2], now.back());
                }
                for (ll i = 0; i < all.size(); i++) {
                        all[i] = now[i].second;
                }
                return;
        }
        ll x = rnd() % all.size();
        ll now = all[x];
        cout << now << '\n';
        vector<ll> sm, bi;
        for (ll j = 0; j < all.size(); j++) {
                if (j != x) {
                        if (Query(now, all[j])) {
                                cout << "< " << all[j] << '\n';
                                sm.push_back(all[j]);
                        } else {
                                cout << "> " << all[j] << '\n';
                                bi.push_back(all[j]);
                        }
                }
        }
        s(sm);
        s(bi);
        if (!sm.empty() && !bi.empty()) {
                swap(sm.back(), bi[0]);
        }
        all.clear();
        for (auto i : sm) {
                all.push_back(i);
        }
        all.push_back(now);
        for (auto i : bi) {
                all.push_back(i);
        }
}

vector<ll> Solve(ll n) {
        vector<ll> all;
        for (ll i = 0; i < n; i++) {
                all.push_back(i);
        }
        s(all);
        vector<ll> ans(n);
        for (ll i = 0; i < n; i++) {
                ans[all[i]] = i;
        }
        return ans;
}

Compilation message

monster.cpp: In function 'void s(std::vector<int>&)':
monster.cpp:24:34: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |                 for (ll i = 0; i < all.size(); i++) {
      |                                ~~^~~~~~~~~~~~
monster.cpp:26:42: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |                         for (ll j = 0; j < all.size(); j++) {
      |                                        ~~^~~~~~~~~~~~
monster.cpp:45:34: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |                 for (ll i = 0; i < all.size(); i++) {
      |                                ~~^~~~~~~~~~~~
monster.cpp:54:26: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |         for (ll j = 0; j < all.size(); j++) {
      |                        ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 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 0 ms 344 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 112 ms 3864 KB Output is correct
17 Correct 134 ms 3552 KB Output is correct
18 Correct 100 ms 4388 KB Output is correct
19 Correct 112 ms 3436 KB Output is correct
20 Correct 107 ms 3540 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 103 ms 3272 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 344 KB Output is correct
32 Correct 101 ms 4180 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 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 0 ms 344 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 112 ms 3864 KB Output is correct
17 Correct 134 ms 3552 KB Output is correct
18 Correct 100 ms 4388 KB Output is correct
19 Correct 112 ms 3436 KB Output is correct
20 Correct 107 ms 3540 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 103 ms 3272 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 344 KB Output is correct
32 Correct 101 ms 4180 KB Output is correct
33 Incorrect 129 ms 4520 KB Wrong Answer [6]
34 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 149 ms 4364 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -