Submission #153572

#TimeUsernameProblemLanguageResultExecution timeMemory
153572asifthegreatArranging Shoes (IOI19_shoes)C++14
10 / 100
1076 ms3196 KiB
#include <bits/stdc++.h> using namespace std; // #include <queue> #include "shoes.h" long long count_swaps(std::vector<int> s) { int cnt = 0; for(int i = 0; i < s.size();i++){ for(int j = i+1; j < s.size();j++){ if(s[i] == -s[j]){ for(int p = j;p > i+1;p--){ swap(s[p],s[p-1]); cnt++; } if(i%2==0 and s[i] > 0)swap(s[i],s[i+1]),cnt++; i++; } } } return cnt; } // int main() { // int n; // scanf("%d", &n); // vector<int> S(2 * n); // for(int i = 0; i < 2 * n; i++) // scanf("%d", &S[i]); // long long result = count_swaps(S); // printf("%lld\n", result); // return 0; // }

Compilation message (stderr)

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