Submission #305942

#TimeUsernameProblemLanguageResultExecution timeMemory
305942kylych03Arranging Shoes (IOI19_shoes)C++14
50 / 100
1090 ms5496 KiB
#include "shoes.h" #include <bits/stdc++.h> //#include "grader.cpp" using namespace std; long long res[200010]; int vis[200011]; long long count_swaps(std::vector<int> s) { long long sum = 0; for(int i = 0 ; i < s.size(); i++){ if(vis[i]==1) continue; int j = i+1; while( 1 ){ if(s[i] == (-1)*s[j] && vis[j]==0) break; res[j]++; j++; } sum += (j - i - 1 + (res[j] - res[i])); if(s[i] > 0) sum++; vis[j]=1; } return sum; }

Compilation message (stderr)

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