제출 #352260

#제출 시각아이디문제언어결과실행 시간메모리
352260spike1236Arranging Shoes (IOI19_shoes)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define ll long long
#define ld long double
#define all(_v) _v.begin(), _v.end()
#define sz(_v) (int)_v.size()
#define pii pair <int, int>
#define pll pair <ll, ll>
#define veci vector <int>
#define vecll vector <ll>


const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const double PI = 3.1415926535897932384626433832795;
const double eps = 1e-9;
const int MOD1 = 1e9 + 7;
const int MOD2 = 998244353;

const int MAXN = 2e5 + 10;
int a[MAXN];

void solve() {
    int n;
    cin >> n;
    bool ch5 = 0;
    for(int i = 1; i <= 2 * n; ++i) {
        cin >> a[i];
        if(i > n && -a[i - n] != a[i])
            ch5 = 1;
        if(i <= n && a[i] > 0)
            ch5 = 1;
        if(i > n && a[i] < 0)
            ch5 = 1;
    }
    if(n == 1) {
        cout << (a[1] > 0);
        return;
    }
    if(!ch5) {
        cout << n * 1ll * (n - 1) / 2;
        return;
    }
    int ans = 0;
    if(n <= 1000) {
        for(int i = 1; i <= 2 * n; i += 2) {
            if(a[i] > 0) {
                for(int j = i + 1; j <= 2 * n; ++j) {
                    if(a[j] == -a[i]) {
                        for(int k = j; k > i; --k)
                            ++ans, swap(a[k], a[k - 1]);
                        break;
                    }
                }
            } else {
                for(int j = i + 1; j <= 2 * n; ++j) {
                    if(-a[j] == a[i]) {
                        for(int k = j; k > i + 1; --k)
                            ++ans, swap(a[k], a[k - 1]);
                        break;
                    }
                }
            }
        }
    }
    cout << ans;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int T = 1;
    ///cin >> T;
    while(T--) solve(), cout << '\n';
    return 0;
}

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

/tmp/ccPeH5YA.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccOIXAZX.o:shoes.cpp:(.text.startup+0x0): first defined here
/tmp/ccPeH5YA.o: In function `main':
grader.cpp:(.text.startup+0x278): undefined reference to `count_swaps(std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status