Submission #390685

#TimeUsernameProblemLanguageResultExecution timeMemory
390685JimmyZJXArranging Shoes (IOI19_shoes)C++14
50 / 100
1094 ms3120 KiB
#include <iostream> #include <fstream> #include <algorithm> #include <cstring> #include <climits> #include <cassert> #include <tuple> #include <queue> #include <stack> #include <vector> #include <map> #include <set> #include <string> #include <unordered_set> #include <unordered_map> using namespace std; typedef long long LL; typedef vector<int> Vi; typedef vector<bool> Vb; typedef vector<vector<int>> Vii; #define forR(i, n) for (int i = 0; i < (n); i++) LL count_swaps(Vi S) { int n = S.size() / 2; LL ans = 0; forR(i, n) { int p = i * 2; int Sp = S[p]; int q = p + 1; while (S[q] != -Sp) q++; while (q > p + 1) { swap(S[q], S[q - 1]); q--; ans++; } if (S[p] > 0) ans++; } return ans; } #ifdef TEST_LOCAL int main() { auto c = count_swaps(Vi{ 2, 1, -1, -2 }); c = count_swaps(Vi{ -2, 2, 2, -2, -2, 2 }); return 0; } #endif
#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...