제출 #826735

#제출 시각아이디문제언어결과실행 시간메모리
826735kevinsogoArranging Shoes (IOI19_shoes)C++17
50 / 100
1092 ms31740 KiB
#include <bits/stdc++.h> using namespace std; #include "shoes.h" using ll = long long; ll count_swaps(vector<int> _seq) { unordered_map<ll,int> found; vector<ll> seq; for (int v : _seq) seq.push_back(ll(v) * _seq.size() + ((v > 0) - (v < 0)) * found[v]++); unordered_map<ll,int> pos; for (int i = 0; i < seq.size(); i++) pos[seq[i]] = i; sort(seq.begin(), seq.end(), [&](int i, int j) { int d = min(pos[i], pos[-i]) - min(pos[j], pos[-j]); return d ? d < 0 : i < j; }); vector<int> targ; for (int v : seq) targ.push_back(pos[v]); ll ans = 0; for (int j = 0; j < targ.size(); j++) { for (int i = 0; i < j; i++) if (targ[i] > targ[j]) ans++; } return ans; }

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

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