Submission #558122

#TimeUsernameProblemLanguageResultExecution timeMemory
558122imalcokArranging Shoes (IOI19_shoes)C++17
10 / 100
1 ms304 KiB
#include "shoes.h" #include <iostream> using namespace std; long long count_swaps(std::vector<int> S){ long long c = 0; int g[S.size()] = {0}; for (int i = 0; i < S.size(); i++) { if (g[i]) continue; else if (S[i] < 0){ int j = i+1; while (S[j] != (-1)*S[i] || g[j]) j++; g[j] = 1; c += (long long)(j-i-1); } else { int j = i+1; while(S[j] != (-1)*S[i] || g[j]) j++; g[j] = 1; c += (long long)(j-i); } } return c; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:9:23: 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 < S.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...