Submission #653893

#TimeUsernameProblemLanguageResultExecution timeMemory
653893aryan12Arranging Shoes (IOI19_shoes)C++17
10 / 100
1 ms300 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; long long count_swaps(vector<int> A) { long long ans = 0; map<int, queue<int> > mp; for(int i = 0; i < A.size(); i++) { // cout << "holyfuck" << endl; if(mp[-A[i]].size() == 0) { mp[A[i]].push(i); continue; } int pos = mp[-A[i]].front(); mp[-A[i]].pop(); // cout << "i = " << i << ", pos = " << pos << endl; for(int j = i; j > pos + 1; j--) { swap(A[j], A[j - 1]); ans++; } if(A[pos] > A[pos + 1]) { swap(A[pos], A[pos + 1]); ans++; } } return ans; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:9:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |  for(int i = 0; i < A.size(); i++)
      |                 ~~^~~~~~~~~~
#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...