제출 #314556

#제출 시각아이디문제언어결과실행 시간메모리
314556baibhav26062008Arranging Shoes (IOI19_shoes)C++14
10 / 100
1 ms256 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; long long count_swaps(std::vector<int> s) { int n = s.size()/2; if (n == 1) { if (s[0] < s[1]) { return 0; } else { return 1; } } long long ans=0; for (int i = 0; i < n; i++) { ans+=i; } bool all_equal = true; for (int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { if (i != j) { if (abs(s[i]) != abs(s[j])) { all_equal = false; break; } } } if (all_equal == false) break; } if (all_equal) { ans = 0; for (int i = 0;i < s.size(); i++) { if (abs(s[i])) { for (int j = i;j < s.size(); j++) { if (abs(s[i]) == abs(s[j])) { ans += abs(j - i); } if (s[i] > s[j]) { ans++; } } } } } return ans; }

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

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