Submission #247015

#TimeUsernameProblemLanguageResultExecution timeMemory
247015ernestvwArranging Shoes (IOI19_shoes)C++17
0 / 100
5 ms256 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; ll subtask3(vector<int> S) { int n = (int)S.size(); ll ans = 0; return ans; } ll subtask4(vector<int> S) { int n = (int)S.size(); ll ans = 0; for(int i = 0; i < n; ++i) { ans += (ll)i; } return ans; } ll count_swaps(vector<int> S) { int n = (int)S.size(); ll ans = 0; vector<bool> prise(n, false); bool sub3 = false; for(int i : S) if(abs(i) != abs(S[0])) sub3 = false; if(sub3) return subtask3(S); bool sub4 = true; for(int i = 0; i < n / 2; ++i) if(S[i] > 0 || S[i + n/2] < 0 || -S[i] != S[i + n/2]) sub4 = false; if(sub4) return subtask4(S); vector<set<int>> L(n+1), R(n+1); int i = 0; while(i < n) { if(S[i] < 0) { int j = -1; for(int k = i + 1; k < n; ++k) if(S[k] == -S[i]) { j = k; break; } for(int l = j; l > i + 1; --l) swap(S[l], S[l-1]), ++ans; } else { if(i > 0 && S[i-1] == -S[i]) { ++i; continue; } int j = -1; for(int k = i + 1; k < n; ++k) if(S[k] == -S[i]) { j = k; break; } for(int l = j; l > i; --l) swap(S[l], S[l-1]), ++ans; } i++; } return ans; }

Compilation message (stderr)

shoes.cpp: In function 'll subtask3(std::vector<int>)':
shoes.cpp:7:6: warning: unused variable 'n' [-Wunused-variable]
  int n = (int)S.size();
      ^
#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...