library

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub matumoto1234/library

:warning: tools/sorted-index.hpp

Depends on

Code

#pragma once

#include "./base.hpp"

#include <numeric>
#include <vector>

namespace matumoto {
  template <typename Iterator>
  vector<int> sorted_index(Iterator first, Iterator last) {
    using T = remove_reference_t<decltype(*first)>;
    vector<T> a(first, last);
    vector<int> res(a.size());
    iota(res.begin(), res.end(), 0);
    stable_sort(res.begin(), res.end(), [&](int i, int j) {
      return a[i] < a[j];
    });
    return res;
  }
} // namespace matumoto
#line 2 "tools/sorted-index.hpp"

#line 2 "tools/base.hpp"

namespace matumoto {
  using namespace std;
}
#line 4 "tools/sorted-index.hpp"

#include <numeric>
#include <vector>

namespace matumoto {
  template <typename Iterator>
  vector<int> sorted_index(Iterator first, Iterator last) {
    using T = remove_reference_t<decltype(*first)>;
    vector<T> a(first, last);
    vector<int> res(a.size());
    iota(res.begin(), res.end(), 0);
    stable_sort(res.begin(), res.end(), [&](int i, int j) {
      return a[i] < a[j];
    });
    return res;
  }
} // namespace matumoto
Back to top page