제출 #289815

#제출 시각아이디문제언어결과실행 시간메모리
289815IgorIArranging Shoes (IOI19_shoes)C++17
50 / 100
1091 ms3200 KiB
#include <vector> #include <cstdio> #include <string> #include <set> #include <cstdlib> #include <iostream> #include <map> using namespace std; #define all(x) (x).begin(), (x).end() #define forn(i, n) for (int (i) = 0; (i) < (n); (i)++) long long count_swaps(vector<int> a) { int n = a.size() / 2; long long ans = 0; for (int i = 0; i < a.size(); i += 2) { int p; for (int j = i; j < a.size(); j++) { if (a[j] == -a[i]) { p = j; break; } } while (p != i + 1) { swap(a[p], a[p - 1]); p--; ans++; } if (a[i] > a[i + 1]) { swap(a[i], a[i + 1]); ans++; } } return ans; }

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

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:18:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |     for (int i = 0; i < a.size(); i += 2)
      |                     ~~^~~~~~~~~~
shoes.cpp:21:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |         for (int j = i; j < a.size(); j++)
      |                         ~~^~~~~~~~~~
shoes.cpp:16:9: warning: unused variable 'n' [-Wunused-variable]
   16 |     int n = a.size() / 2;
      |         ^
shoes.cpp:20:13: warning: 'p' may be used uninitialized in this function [-Wmaybe-uninitialized]
   20 |         int p;
      |             ^
#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...