Submission #715926

# Submission time Handle Problem Language Result Execution time Memory
715926 2023-03-28T12:43:30 Z ismayil Art Collections (BOI22_art) C++17
Compilation error
0 ms 0 KB
#include "art.h"
#include<bits/stdc++.h>
using namespace std;
//     g++ -std=c++17 art_sample.cpp sample_grader.cpp
int n;
int f(){
    vector<int> order;
    for (int i = 1; i <= n; i++)
    {
        order.push_back(i);
    }
    return publish(order);
}
int f_inv(int a){
    vector<int> order;
    
    for (int i = 1; i <= n; i++)
    {
        if(i == a) continue;
        order.push_back(i);
    }
    order.push_back(a);
    return publish(order);
}
int cell[4001];
void solve(int N) {
    n = N;
    vector<int> ans(n, 0);
    int inv = f();
    for (int i = 1; i < n; i++)
    {
        int ninv = f_inv(i);
        /*
            inv = x + y + pos(i);
            ninv = n - i - pos(i) + x + y;
            inv - ninv = pos(i) - n + i + pos(i)
            2 * pos(i) = inv - ninv + n - i
        */
        int pos = (inv - ninv + n - i) / 2;
        //cout << i << " " << pos << endl;
        for(int j = 0; j < n; j++){
            if(cell[j] == 0 && pos == 0){
                ans[j] = i;
                cell[j] = 1;
                break;
            }
            if(cell[j] == 0) pos--;
        }
    }
    for(int j = 0; j < n; j++){
        if(cell[j] == 0){
            ans[j] = i;
            cell[j] = 1;
            break;
        }
    }
    answer(ans);
}

Compilation message

art.cpp: In function 'void solve(int)':
art.cpp:52:22: error: 'i' was not declared in this scope
   52 |             ans[j] = i;
      |                      ^
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) {
      |        ~~~~~~~~~^~~~