제출 #826773

#제출 시각아이디문제언어결과실행 시간메모리
826773kevinsogoArranging Shoes (IOI19_shoes)C++17
0 / 100
1 ms340 KiB
#include <bits/stdc++.h> using namespace std; #include "shoes.h" using ll = long long; struct Seg { int i, j; int s = 0; Seg *l, *r; Seg(int i, int j): i(i), j(j) { if (j - i == 1) { l = r = nullptr; } else { int k = i + j >> 1; l = new Seg(i, k); r = new Seg(k, j); } } int inc(int I) { if (i <= I and I < j) { s++; if (l) l->inc(I), r->inc(I); } } int sum(int I) { return j <= I ? s : I <= i ? 0 : l->sum(I) + r->sum(I); } }; ll count_swaps(vector<int> _seq) { vector<int> found(_seq.size() * 2 + 5); vector<ll> seq; for (int v : _seq) seq.push_back(ll(v) * _seq.size() + ((v > 0) - (v < 0)) * found[v + _seq.size()]++); unordered_map<ll,int> pos; pos.max_load_factor(0.5); for (int i = 0; i < seq.size(); i++) pos[seq[i]] = i; sort(seq.rbegin(), seq.rend(), [&](ll i, ll j) { int d = min(pos[i], pos[-i]) - min(pos[j], pos[-j]); return d ? d < 0 : i < j; }); for (ll& v : seq) v = pos[v]; ll ans = 0; Seg s(0, seq.size()); for (ll v : seq) ans += s.sum(v), s.inc(v); return ans; }

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

shoes.cpp: In constructor 'Seg::Seg(int, int)':
shoes.cpp:14:23: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   14 |             int k = i + j >> 1;
      |                     ~~^~~
shoes.cpp: In member function 'int Seg::inc(int)':
shoes.cpp:24:5: warning: no return statement in function returning non-void [-Wreturn-type]
   24 |     }
      |     ^
shoes.cpp: In function 'll count_swaps(std::vector<int>)':
shoes.cpp:35:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     for (int i = 0; i < seq.size(); i++) pos[seq[i]] = i;
      |                     ~~^~~~~~~~~~~~
#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...