제출 #597937

#제출 시각아이디문제언어결과실행 시간메모리
597937supercatexArranging Shoes (IOI19_shoes)C++14
10 / 100
1 ms300 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; long long count_swaps(vector<int> s) { int res = 0; for (int i = 0; i < s.size(); i += 2) { if (s[i] > 0) { for (int j = i + 1; j < s.size(); j++) { if (s[j] == -s[i]) { s.erase(s.begin() + j); s.insert(s.begin() + i, -s[i]); res += j - i; break; } } } else if (s[i] != -s[i + 1]) { for (int j = i + 2; j < s.size(); j++) { if (s[j] == -s[i]) { s.erase(s.begin() + j); s.insert(s.begin() + i + 1, -s[i]); res += j - i - 1; } } } } return res; }

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

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