Submission #243086

#TimeUsernameProblemLanguageResultExecution timeMemory
243086idtjArranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define int long long using namespace std; signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); freopen("input.txt", "r", stdin); int n; cin >> n; vector<deque<pair<int, int>>> a(n + 1); // pos / is_left vector<pair<int, int>> in(n * 2); // size / is_left for (int i = 0; i < n * 2; ++i) { int now; cin >> now; if (now < 0) { in[i].second = 1; now = -now; } in[i].first = now; } int ans = 0; for (int i = 0; i < n * 2; ++i) { auto &t = a[abs(in[i].first)]; if (t.empty() || t.front().second == in[i].second) { t.push_back(make_pair(i, in[i].second)); } else { if (t.front().second) { ans += i - t.front().first - 1; } else ans += i - t.front().first; t.pop_front(); } } cout << ans << endl; return 0; }

Compilation message (stderr)

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