Submission #1033726

#TimeUsernameProblemLanguageResultExecution timeMemory
1033726enderArranging Shoes (IOI19_shoes)C++17
0 / 100
0 ms348 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; long long count_swaps(std::vector<int> s) { vector<bool> visited(s.size(), false); vector<int> ns(s.size()); // new s int pos = 1; for(int i = 0; i < s.size(); ++i){ if(visited[i]) continue; int goal = -s[i]; for(int j = i+1; j < s.size(); ++j){ if(visited[j]) continue; if(s[j] == goal){ if(s[j] > 0){ ns[j] = pos; ns[i] = -pos; } else { ns[j] = -pos; ns[i] = pos; } visited[i] = true; visited[j] = true; pos++; break; } } } for(const auto &i : ns) cout << i << " "; cout << "\n"; return 0; }

Compilation message (stderr)

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