Submission #216999

#TimeUsernameProblemLanguageResultExecution timeMemory
216999thatprogrammerArranging Shoes (IOI19_shoes)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    if (fopen("input.in", "r")) {
        freopen("input.in", "r", stdin);
        freopen("output.out", "w", stdout);
    }
    int n;
    cin >> n;
    int s[100000];
    for (int i = 0; i < 2 * n; i++) {
        cin >> s[i];
    }
    ll ans = 0;
    for (int i = 0; i < 2 * n; i += 2) {
        int j;
        for (j = i + 1; j < 2 * n; j++) {
            if (s[j] == -s[i]) break;
        }
        if (s[i] < 0)
            ans += j - i - 1;
        else
            ans += j - i;
        for (; j > i; j--) swap(s[j], s[j - 1]);
    }
    cout << ans << endl;
}

Compilation message (stderr)

shoes.cpp: In function 'int main()':
shoes.cpp:8:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
         freopen("input.in", "r", stdin);
         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
shoes.cpp:9:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
         freopen("output.out", "w", stdout);
         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/cc0O70jL.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/cck9zstn.o:shoes.cpp:(.text.startup+0x0): first defined here
/tmp/cc0O70jL.o: In function `main':
grader.cpp:(.text.startup+0x282): undefined reference to `count_swaps(std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status