Submission #335463

#TimeUsernameProblemLanguageResultExecution timeMemory
335463MohammadHijazArranging Shoes (IOI19_shoes)C++14
50 / 100
1093 ms1900 KiB
#include "shoes.h" #include<bits/stdc++.h> using namespace std; long long count_swaps(std::vector<int> s) { int x = s.size(); int last = 0; long long ans = 0; for (int i = 0; i < x; i += 2) { int tar; for (int j = i + 1; j < x; j++) { if (s[j] == s[i]*-1) { tar = j; break; } } while(i + 1 != tar) { swap(s[tar] , s[tar - 1]); tar--; ans++; } if (s[i] > s[i + 1]) { swap(s[i + 1] , s[i]); ans++; } } return ans; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:6:6: warning: unused variable 'last' [-Wunused-variable]
    6 |  int last = 0;
      |      ^~~~
shoes.cpp:9:17: warning: 'tar' may be used uninitialized in this function [-Wmaybe-uninitialized]
    9 |             int tar;
      |                 ^~~
#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...