제출 #423572

#제출 시각아이디문제언어결과실행 시간메모리
423572schseArranging Shoes (IOI19_shoes)C++17
50 / 100
1108 ms272656 KiB
#include "shoes.h" #ifndef EVAL #include "grader.cpp" #endif #include <bits/stdc++.h> using namespace std; long long count_swaps(std::vector<int> s) { vector<int> posadd(s.size()); vector<bool> sorted(s.size(), false); vector<stack<int>> pleft(s.size() + 1), plright(s.size() + 1); iota(posadd.begin(), posadd.end(), 0); long long numswaps = 0; for (int e, i = 0; i < s.size(); i++) { if (sorted[i]) continue; for (e = i + 1; e < s.size(); e++) { if (s[i] == -s[e] && !sorted[e]) break; } sorted[i] = sorted[e] = true; for (int c = i + 1; c < e; c++) posadd[c]++; numswaps += posadd[e] - posadd[i] - 1; if (s[i] > 0) numswaps++; } return numswaps; }

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

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