답안 #1057077

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1057077 2024-08-13T13:56:22 Z GrindMachine Monster Game (JOI21_monster) C++17
0 / 100
64 ms 2000 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define setbits(x) __builtin_popcountll(x)
#define ff first
#define ss second
#define conts continue
#define ceil2(x,y) ((x+y-1)/(y))
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define yes cout << "Yes" << endl
#define no cout << "No" << endl

#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
#define rev(i,s,e) for(int i = s; i >= e; --i)
#define trav(i,a) for(auto &i : a)

template<typename T>
void amin(T &a, T b) {
    a = min(a,b);
}

template<typename T>
void amax(T &a, T b) {
    a = max(a,b);
}

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

/*

refs:
https://codeforces.com/blog/entry/91295?#comment-801014

*/

const int MOD = 1e9 + 7;
const int N = 1e5 + 5;
const int inf1 = int(1e9) + 5;
const ll inf2 = ll(1e18) + 5;

#include "monster.h"

namespace {

bool example_variable;

}  // namespace

std::vector<int> Solve(int n) {
  // std::vector<int> T(N);

  // example_variable = Query(0, 1);

  // for (int i = 0; i < N; i++) T[i] = (N - 1) - i;

  // return T;

    vector<int> a(n);
    iota(all(a),0);
    map<pii,bool> mp;
    int q = 0;

    auto f = [&](int i, int j){
        if(mp.count({i,j})) return mp[{i,j}];
        q++;
        bool res = Query(i,j);
        mp[{i,j}] = res, mp[{j,i}] = res^1;
        return res;
    };

    auto cmp = [&](int i, int j){
        return !f(i,j);
    };

    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    shuffle(all(a),rng);
    stable_sort(all(a),cmp);

    auto win_count = [&](int i){
        int ans = 0;
        rep(j,n){
            if(j != i){
                ans += f(i,j);
            }
        }

        return ans;
    };

    vector<pii> blocks;

    if(f(a[0],a[1])){
        blocks.pb({0,0});
        blocks.pb({1,1});
    }
    else{
        if(win_count(a[1]) > 1){
            blocks.pb({0,0});            
        }
        else{
            blocks.pb({0,1});
        }
    }

    int s = blocks.back().ss+1;
    for(int i = s; i < n; ++i){
        if(f(a[blocks.back().ff],a[i])){
            blocks.pb({blocks.back().ss+1,i});
        }
    }

    vector<int> ans(n);
    int ptr = 0;
    for(auto [l,r] : blocks){
        rev(i,r,l){
            ans[a[i]] = ptr++;
        }
    }

    return ans;
}

Compilation message

monster.cpp:65:6: warning: '{anonymous}::example_variable' defined but not used [-Wunused-variable]
   65 | 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 1 ms 344 KB Output is correct
5 Incorrect 0 ms 344 KB Wrong Answer [3]
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 1 ms 344 KB Output is correct
5 Incorrect 0 ms 344 KB Wrong Answer [3]
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 56 ms 1676 KB Partially correct
2 Partially correct 57 ms 2000 KB Partially correct
3 Partially correct 56 ms 1600 KB Partially correct
4 Partially correct 55 ms 1928 KB Partially correct
5 Partially correct 64 ms 1580 KB Partially correct
6 Incorrect 55 ms 1576 KB Wrong Answer [3]
7 Halted 0 ms 0 KB -