Submission #1007451

# Submission time Handle Problem Language Result Execution time Memory
1007451 2024-06-25T01:50:47 Z kebine Art Collections (BOI22_art) C++17
Compilation error
0 ms 0 KB
#include "art.h"
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()

// int publish(vector<int> B) {
//     answer(B);
//     int ans;cin>>ans;
//     return ans;
// }

// void answer(vector<int> B) {
//     for (auto el : B) cout << el << " ";
//     cout << endl;
// }

// A = [5, 2, 3, 1, 4], inv = 4 + 1 + 1 = 6
// A = [2, 3, 1, 4, 5], inv = 1 + 1 = 2
// A = [3, 1, 4, 5, 2], inv = 2 + 1 + 1 = 4
// A = [1, 4, 5, 2, 3], inv = 2+2 = 4
// A = [4, 5, 2, 3, 1], inv = 3+3+2 = 8

void solve(int n) {
    vector<int> a(n);
    iota(all(a),1);

    vector<int> rec(n);

    vector<int> ans;
    for (int i = 0; i < n; i++) {
        int x = publish(a);
        a.push_back(*a.begin());
        a.erase(a.begin());
        ans.push_back(x);
    }

    vector<pair<int, int>> delt(n);
    for (int i = 0; i < n; i++) {
        delt[i] = {ans[(i+1)%n] - ans[i], i};
    }
    
    sort(all(delt));
    reverse(all(delt));
    for (int i = 0; i < n; i++) rec[i] = delt[i].second+1;

    answer(rec);
}

int main() {
    int n;cin>>n;
    solve(n);
}

Compilation message

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/ccHIhu60.o: in function `main':
interface.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccddn9O0.o:art.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status