Submission #158248

#TimeUsernameProblemLanguageResultExecution timeMemory
158248redaArranging Shoes (IOI19_shoes)C++14
50 / 100
1076 ms3192 KiB
#include<bits/stdc++.h> using namespace std ; long long count_swaps (vector<int>s) { int n = s.size(); bool c=1; long long ans = 0 ; for(int i = 0 ;i<n/2;i++) { if(s[i]!=-s[2*i-1])c=0; } n=n/2; if(c)return n*(n-1)/2LL; for(int i = 0 ;i < s.size();i+=2) { int j = i+1; while(s[i]!=-s[j]) { j++; } while (j!=i+1) { swap(s[j],s[j-1]); ans++; j--; } if(s[j]<0) { swap(s[i],s[j]); ans++; } } return ans; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:14:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       for(int i = 0 ;i < s.size();i+=2)
                      ~~^~~~~~~~~~
#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...