제출 #532201

#제출 시각아이디문제언어결과실행 시간메모리
532201andecaandeciArranging Shoes (IOI19_shoes)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>    

using namespace std;
using ll = long long;

ll count_swaps(vector<int>v){
    ll n = v.size();
    bool st4 = true;
    ll ans = 0;

    for(ll i = 0; i < n/2; i++){
        if(v[i] != -v[n/2 + i] || v[i] > 0){
            st4 = false;
            break;
        }
    }

    if(st4 && n > 2){
        ll x = (n/2)*(n/2 - 1)/2;
        return x;
    }

    for(ll i = 0; i < n; i++){
        ll cur = v[i]; 
        ll l = -1;

        for(ll j = i - 1; j >= 0; j--){
            if(v[j] == -cur) l = j;
        }

        if(l != -1){
            ans += (i - l - (v[i] > 0));
            for(ll j = i; j > l; j--) swap(v[j], v[j - 1]);
            v[l] = v[l + 1] = 0;
        }
    }

    return ans;
}

int main(){
    int n; cin >> n;
    vector<int>arr(n);

    for(int i = 0; i < n; i++) cin >> arr[i];

    cout << count_swaps(arr) << endl;

    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

/usr/bin/ld: /tmp/cc43bYIe.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccHVUd2d.o:shoes.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status