Submission #537291

#TimeUsernameProblemLanguageResultExecution timeMemory
537291ERHArranging Shoes (IOI19_shoes)C++14
10 / 100
1 ms308 KiB
#include <iostream> #include <vector> using namespace std; int lista[100000][2]; long long count_swaps(vector<int> v){ long long int total=0; for(int i=0; i<v.size(); ++i){ int a=v[i]; if(a<0){ a=-a; lista[a][1]=i+1; if(lista[a][0]){ total+=lista[a][1]-lista[a][0]; lista[a][1]=lista[a][0]=0; } } else { lista[a][0]=i+1; if(lista[a][1]){ total+=lista[a][0]-lista[a][1]-1; lista[a][1]=lista[a][0]=0; } } } return total; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:7:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 |   for(int i=0; i<v.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...