Submission #153574

#TimeUsernameProblemLanguageResultExecution timeMemory
153574asifthegreatArranging Shoes (IOI19_shoes)C++14
0 / 100
2 ms256 KiB
#include <bits/stdc++.h> using namespace std; // #include <queue> #include "shoes.h" long long count_swaps(std::vector<int> s) { int cnt = 0; int sz = s.size(); for(int i = 0; i < s.size();i++){ if(i < sz/2)s[i] = -(i+1); else s[i] = (i+1-sz/2); } for(int i = 0; i < sz;i++){ cout << s[i] << " "; }cout << endl; 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:9:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < s.size();i++){
                 ~~^~~~~~~~~~
shoes.cpp:16:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < s.size();i++){
                 ~~^~~~~~~~~~
shoes.cpp:17: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...