답안 #714229

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
714229 2023-03-24T06:46:50 Z vjudge1 Art Collections (BOI22_art) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define size(v) v.size()
#define all(v) v.begin(), v.end()
#define INF 2e9
#define f first
#define s second

using namespace std;

const int up = 4005;

int N;
vector<int>a, in1, in2;

int publish(std::vector<int>R){
    for(int i = 0; i < N; i++){
        in2[R[i]] = i;
    }
    int cnt = 0;
    for(int i = 0; i < N; ++i){
        for(int j = 0; j < N; j++){
            if(a[i] != R[j]){
                if(in1[R[j]] > in1[a[i]] && in2[R[j]] < in2[a[i]]){
                    cnt++;
                }
            }
        }
    }
    return cnt;
}

void answer(std::vector<int>R){
    for(int i : R){
        cout << i << " ";
    }
    cout << "\n";
}

void solve(int N){
    sort(all(a));
    do{
        if(!publish(a)){
            answer(a);
            return;
        }
    }
    while(next_permutation(all(a)));        
}

void grader(){
    cin >> N;
    a.resize(N), in1.resize(N), in2.resize(N);
    for(int i = 0; i < N; ++i){
        cin >> a[i];
        in1[a[i]] = i;
    }
    solve(N);
}


int main()
{
    grader();
}

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