結果
問題 | No.670 log は定数 |
ユーザー | ei1333333 |
提出日時 | 2018-03-23 22:58:10 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 2,286 bytes |
コンパイル時間 | 2,656 ms |
コンパイル使用メモリ | 210,628 KB |
実行使用メモリ | 785,424 KB |
最終ジャッジ日時 | 2024-06-24 22:39:10 |
合計ジャッジ時間 | 29,928 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | MLE | - |
testcase_01 | MLE | - |
testcase_02 | MLE | - |
testcase_03 | MLE | - |
testcase_04 | MLE | - |
testcase_05 | MLE | - |
testcase_06 | MLE | - |
testcase_07 | MLE | - |
testcase_08 | MLE | - |
testcase_09 | MLE | - |
コンパイルメッセージ
main.cpp:60:32: warning: 'template<class _Arg, class _Result> struct std::unary_function' is deprecated [-Wdeprecated-declarations] 60 | struct get_key_t : public std::unary_function<val_t,key_type> | ^~~~~~~~~~~~~~ In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/string:48, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/locale_classes.h:40, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/ios_base.h:41, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ios:42, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/istream:38, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/sstream:38, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/complex:45, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ccomplex:39, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/x86_64-pc-linux-gnu/bits/stdc++.h:54, from main.cpp:1: /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_function.h:117:12: note: declared here 117 | struct unary_function | ^~~~~~~~~~~~~~
ソースコード
#include<bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; typedef int key_type; template <int UNIT, int BITS, class RAI, class G> void radix_sort(RAI a0, RAI aN, G get_key) { typedef typename std::iterator_traits<RAI>::value_type val_t; typedef typename std::iterator_traits<RAI>::difference_type dif_t; typedef typename G::result_type key_type; static const int KEYS = 1 << UNIT; static const int MASK = KEYS - 1; const dif_t N = aN - a0; const RAI& a = a0; if (N < 2) return; std::vector<dif_t> h(KEYS); std::vector<val_t> b(N); const typename std::vector<val_t>::iterator b0 = b.begin(); const typename std::vector<val_t>::iterator bN = b.end(); for (int shift = 0; shift < BITS; shift += UNIT) { for (int k = 0; k < KEYS; k++) h[k] = 0; typename std::vector<val_t>::iterator bi = b0; bool done = true; for (RAI ai = a0; ai < aN; ++ai, ++bi) { const val_t& x = *ai; const key_type y = get_key(x) >> shift; if (y > 0) done = false; ++h[int(y & MASK)]; *bi = x; } if (done) return; for (int k = 1; k < KEYS; k++) h[k] += h[k - 1]; for (bi = bN; bi > b0;) { const val_t& x = *(--bi); const int y = int((get_key(x) >> shift) & MASK); const dif_t j = --h[y]; a[j] = x; } } } ull seed; inline int next() { seed = seed ^ (seed << 13); seed = seed ^ (seed >> 7); seed = seed ^ (seed << 17); return (seed >> 33); } struct val_t { key_type key; int data; }; struct get_key_t : public std::unary_function<val_t,key_type> { key_type operator()(const val_t& x) const { return x.key; } }; int main() { int n, q; cin >> n >> q >> seed; for (int i = 0; i < 10000; i++) next(); vector<int> a(n); for (int i = 0; i < n; i++) a[i] = next(); sort(begin(a), end(a)); a.push_back(INT_MAX); ll sm = 0; vector< val_t > rad(q); for (int i = 0; i < q; i++) { rad[i].key = next(); rad[i].data = i; } radix_sort<8,32>(rad.begin(), rad.end(), get_key_t()); int ptr = 0; for(int i = 0; i < q; i++) { auto& p = rad[i]; while(a[ptr] < p.key) ++ptr; sm ^= ll(ptr) * p.data; } cout << sm << endl; }