Submission #1272960

#TimeUsernameProblemLanguageResultExecution timeMemory
1272960arkanefuryArranging Shoes (IOI19_shoes)C++20
50 / 100
1094 ms1964 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; const int N = 2e5+5; int a[N], b[N]; long long count_swaps(vector <int> v){ int n = v.size(), k; long long ans = 0; for(int i = 0; i < n; i += 2){ if(v[i] < 0){ for(int j = i+1; j < n; j ++){ if(v[j] > 0 && v[j] == abs(v[i])){ k = j;break; } } for(int j = k; j > i+1; j --){ swap(v[j], v[j-1]); ans ++; } } else{ for(int j = i+1; j < n; j ++){ if(v[j] < 0 && abs(v[j]) == v[i]){ k = j;break; } } for(int j = k; j > i; j --){ swap(v[j], v[j-1]); ans ++; } } } return ans; }
#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...