Submission #1323991

#TimeUsernameProblemLanguageResultExecution timeMemory
1323991sh_qaxxorov_571Arranging Shoes (IOI19_shoes)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; using int64 = long long; int64 count_swaps(vector<int> S) { int n = S.size(); int64 res = 0; // Chap va o'ng poyabzallarni bir xil o'lcham bo'yicha tartiblaymiz for (int i = 0; i < n; i += 2) { if (S[i] < 0) { // chap bo'lishi kerak edi, o'ng poyabzal // topib, chap poyabzal bilan almashtiramiz int j = i + 1; while (j < n && !(S[j] > 0 && abs(S[j]) == abs(S[i + 1]))) j++; while (j > i) { swap(S[j], S[j - 1]); res++; j--; } } if (S[i + 1] > 0) { // o'ng bo'lishi kerak edi, chap poyabzal int j = i + 2; while (j < n && !(S[j] < 0 && abs(S[j]) == abs(S[i]))) j++; while (j > i + 1) { swap(S[j], S[j - 1]); res++; j--; } } } return res; } // Test qilish int main() { vector<int> S1 = {2, 1, -1, -2}; cout << count_swaps(S1) << endl; // natija: 4 vector<int> S2 = {-2, 2, 2, -2, -2, 2}; cout << count_swaps(S2) << endl; // natija: 2 return 0; }

Compilation message (stderr)

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