제출 #523838

#제출 시각아이디문제언어결과실행 시간메모리
523838pakhomoveeArranging Shoes (IOI19_shoes)C++17
0 / 100
0 ms204 KiB
#include "shoes.h" #include <cmath> using namespace std; long long count_swaps(std::vector<int> s) { const int n = s.size(); long long ans = 0; vector<vector<int>> idPlus(n); vector<vector<int>> idMinus(n); for (int i = 0; i < n; ++i) { if (s[i] > 0) { idPlus[abs(s[i])].push_back(i); } else { idMinus[abs(s[i])].push_back(i); } } for (int i = 0; i < n; ++i) { for (int j = 0; j < idPlus[i].size(); ++j) { if (idPlus[i][j] > idMinus[i][j]) { ans += -(idMinus[i][j] - idPlus[i][j]); } else { ans += -(idPlus[i][j] - idMinus[i][j]) + 1; } } } return ans; }

컴파일 시 표준 에러 (stderr) 메시지

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