Submission #1145650

#TimeUsernameProblemLanguageResultExecution timeMemory
1145650MunkhturErdenebatArranging Shoes (IOI19_shoes)C++20
0 / 100
1094 ms2628 KiB
#include <bits/stdc++.h> using namespace std; long long count_swaps(vector<int> s) { int a = s.size(); vector<int> maa(a, 0); // Initialize array with 0 long long h = 0; for(int i = 0; i < a; i++) { if(maa[i] == 1) continue; int g = -1; // Initialize g to an invalid index for(int j = i + 1; j < a; j++) { if(s[j] + s[i] == 0 && maa[j] == 0) { g = j; break; } } if (g == -1) continue; // No valid pair found, skip for(int j = g - 1; j > i; j--) { if(maa[j] == 0) h++; } maa[g] = 1; // Mark the index as used } return h; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...