Submission #747008

# Submission time Handle Problem Language Result Execution time Memory
747008 2023-05-23T11:49:13 Z pls33 Art Collections (BOI22_art) C++17
Compilation error
0 ms 0 KB
#define _AAAAAAAAA
#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;

#pragma region dalykai
template <typename F>
void _debug(F f)
{
    f();
}

#ifndef _AAAAAAAAA
#define debug(x)
#else
#define debug(x) _debug(x)
#endif
using p32 = pair<int, int>;
using p32u = pair<uint32_t, uint32_t>;
using p64 = pair<int64_t, int64_t>;
using p64u = pair<uint64_t, uint64_t>;
using vi16 = vector<int16_t>;
using vi16u = vector<uint16_t>;
using vi32 = vector<int>;
using vi32u = vector<uint32_t>;
using vi64 = vector<int64_t>;
using vi64u = vector<uint64_t>;
using vp32 = vector<p32>;
using vp32u = vector<p32u>;
using vp64 = vector<p64>;
using vp64u = vector<p64u>;
using vvi32 = vector<vi32>;
using vvi32u = vector<vi32u>;
using vvi64 = vector<vi64>;
using vvi64u = vector<vi64u>;
using vvp32 = vector<vp32>;
using vvp32u = vector<vp32u>;
using vvp64 = vector<vp64>;
using vvp64u = vector<vp64u>;
using f80 = long double;
#pragma endregion

#ifndef _AAAAAAAAA
#include "art.h"
#else
int publish(vector<int> R);
void answer(vector<int> R);
void solve(int N);
#endif

void solve(int n) {
    mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
    std::vector<int> order(n);
    iota(order.begin(), order.end(), 1);

    while(publish(order) > 0){
        shuffle(order.begin(), order.end(), rng);
    }

    answer(order);
}

#ifdef _AAAAAAAAA
void __attribute__((noreturn)) __attribute__((format(printf, 1, 2))) result(const char *msg, ...) {
    va_list args;
    va_start(args, msg);
    vfprintf(stdout, msg, args);
    fprintf(stdout, "\n");
    va_end(args);
    exit(0);
}

namespace {
    int N;
    int Q = 0;
    const int MAX_Q = 4000;
    const int MAX_N = 4000;
    vector<int> solution;
}  // namespace

int publish(vector<int> R) {
    printf("publish({");
    for(int i = 0; i < int(R.size()); ++i) {
        if(i == 0)
            printf("%d", R[i]);
        else
            printf(", %d", R[i]);
    }
    printf("})\n");
    fflush(stdout);

    if (++Q > MAX_Q)
        result("Too many published rankings!");

    if (int(R.size()) != N)
        result("Invalid published ranking!");

    set<int> chosen;
    for(auto &x : R) {
        if(x < 1 || x > N || chosen.count(x))
            result("Invalid published ranking!");
        chosen.insert(x);
    }
    vector<int> positions(N+1);
    for(int i = 0; i < N; ++i)
        positions[R[i]] = i;

    int complaints = 0;
    for(int i = 0; i < N; ++i) {
        for(int j = i+1; j < N; ++j) {
            if(positions[solution[i]] > positions[solution[j]])
                ++complaints;
        }
    }

    return complaints;
}

void __attribute__((noreturn)) answer(vector<int> R) {
    printf("answer({");
    for(int i = 0; i < int(R.size()); ++i) {
        if(i == 0)
            printf("%d", R[i]);
        else
            printf(", %d", R[i]);
    }
    printf("})\n");
    fflush(stdout);


    if(R == solution)
        result("Correct: %d published ranking(s).", Q);
    else
        result("Wrong answer!");
}

int main() {
    freopen("art.in", "r", stdin);
    if (scanf("%d", &N) != 1 || N < 2 || N > MAX_N)
        result("Invalid input!");

    solution.resize(N);
    set<int> chosen;
    for(auto &x : solution) {
        if(scanf("%d", &x) != 1 || x < 1 || x > N || chosen.count(x))
            result("Invalid input!");
        chosen.insert(x);
    }

    solve(N);

    result("No answer!");
}
#endif

Compilation message

art.cpp:9: warning: ignoring '#pragma region dalykai' [-Wunknown-pragmas]
    9 | #pragma region dalykai
      | 
art.cpp:44: warning: ignoring '#pragma endregion ' [-Wunknown-pragmas]
   44 | #pragma endregion
      | 
art.cpp: In function 'int main()':
art.cpp:141:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  141 |     freopen("art.in", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
interface.cpp: In function 'int publish(std::vector<int>)':
interface.cpp:20:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |     if(v.size() != N) {
      |        ~~~~~~~~~^~~~
interface.cpp: In function 'void answer(std::vector<int>)':
interface.cpp:36:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |     if(v.size() != N) {
      |        ~~~~~~~~~^~~~
/usr/bin/ld: /tmp/ccGqaNzk.o: in function `publish(std::vector<int, std::allocator<int> >)':
interface.cpp:(.text+0x60): multiple definition of `publish(std::vector<int, std::allocator<int> >)'; /tmp/ccQl4rrg.o:art.cpp:(.text+0x3b0): first defined here
/usr/bin/ld: /tmp/ccGqaNzk.o: in function `answer(std::vector<int, std::allocator<int> >)':
interface.cpp:(.text+0x170): multiple definition of `answer(std::vector<int, std::allocator<int> >)'; /tmp/ccQl4rrg.o:art.cpp:(.text+0x2b0): first defined here
/usr/bin/ld: /tmp/ccGqaNzk.o: in function `main':
interface.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccQl4rrg.o:art.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status