Submission #832203

#TimeUsernameProblemLanguageResultExecution timeMemory
832203devariaotaArranging Shoes (IOI19_shoes)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
using namespace std;
#define ioss ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define tup tuple<int, int, int>
#define pii pair<int, int>
#define fi first
#define se second
#define pub push_back
#define pob pop_back
int n;
vector<int> s;
int main() {
    ioss;
    cin >> n;
    for(int i = 0; i < 2*n; i++) {
        int a; cin >> a;
        s.pub(a);
    }

    int ans = 0;
    for(int i = 0; i < 2*n; i++) {
        if(s[i] == 0) continue;
        if(s[i] < 0) {
            int cnt = 0;
            for(int j = i+1; j < 2*n; j++) {
                if(s[j] == 0) {
                    cnt++;
                    continue;
                }

                if(s[j] == -s[i]) {
                    ans += j-i-1 - cnt;
                    s[i] = s[j] = 0;
                    break;
                }
            }
        }
        else {
            int cnt = 0;
            for(int j = i+1; j < 2*n; j++) {
                if(s[j] == 0) {
                    cnt++;
                    continue;
                }

                if(s[j] == -s[i]) {
                    ans += j-i - cnt;
                    s[i] = s[j] = 0;
                    break;
                }
            }
        }
    }
    cout << ans << endl;
}

Compilation message (stderr)

/usr/bin/ld: /tmp/cc53xaEj.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cclx3xfi.o:shoes.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/cc53xaEj.o: in function `main':
grader.cpp:(.text.startup+0x2a8): undefined reference to `count_swaps(std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status