Submission #1179515
Source Code Expand
/*** Template Begin ***/
#define USING_BOOST
#define USING_NAMESPACE
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
auto init_ = [] {
std::ios_base::sync_with_stdio(false);
std::cout << std::fixed;
return 0;
}();
template <typename T>
inline T in() {
T x;
std::cin >> x;
return x;
}
template <typename T>
inline void in(T &x) {
std::cin >> x;
}
template <typename T, typename... Ts>
inline void in(T &t, Ts &... ts) {
std::cin >> t;
in(ts...);
}
template <typename T, typename U = std::vector<T>>
inline U vin(int n) {
U v(n);
for (int i = 0; i < n; ++i) {
std::cin >> v[i];
}
return v;
}
template <typename T, typename U = std::vector<T>, typename V = std::vector<U>>
inline V vin(int h, int w) {
V vv(h, U(w));
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
std::cin >> vv[i][j];
}
}
return vv;
}
template <typename T>
inline void out(const T &x) {
std::cout << x << std::endl;
}
template <char delimiter = ' ', typename T, typename... Ts>
inline void out(const T &t, const Ts &... ts) {
std::cout << t << delimiter;
out(ts...);
}
template <char delimiter = ' ', typename T>
inline void vout(const T &v, int n) {
for (int i = 0; i < n; ++i) {
if (i) std::cout << delimiter;
std::cout << v[i];
}
std::cout << std::endl;
}
template <char delimiter = ' ', typename T>
inline void vout(const T &v, int h, int w) {
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
if (j) std::cout << delimiter;
std::cout << v[i][j];
}
std::cout << std::endl;
}
}
template <typename T, size_t D>
struct multi_vector_type {
using type = std::vector<typename multi_vector_type<T, D - 1>::type>;
};
template <typename T>
struct multi_vector_type<T, 1> {
using type = std::vector<T>;
};
template <typename T>
struct multi_vector_type<T, 0> {
using type = T;
};
template <typename T, size_t D>
using multi_vector = typename multi_vector_type<T, D>::type;
template <typename T, size_t D, class = typename std::enable_if<D == 0>::type>
T make_vector(const T &val = T()) {
return val;
}
template <typename T, size_t D = 1, typename... Ts,
class = typename std::enable_if<D != 0>::type>
multi_vector<T, D> make_vector(size_t n, Ts &&... args) {
return multi_vector<T, D>(n, make_vector<T, D - 1>(args...));
}
namespace detail {
template <typename F>
struct Debug {
const char *delim_ = "\n";
F fun;
Debug(F f) : fun(f) {}
~Debug() { fun(delim_); }
Debug &delim(const char *d) {
delim_ = d;
return *this;
}
};
std::deque<std::string> split(const std::string &s, char c) {
std::deque<std::string> v;
std::stringstream ss(s);
std::string x;
while (std::getline(ss, x, c)) v.emplace_back(x);
return v;
}
template <typename T>
void deb(const char *delim, std::deque<std::string> v, T a) {
std::cerr << v[0].substr(v[0][0] == ' ', v[0].length()) << " = " << a
<< '\n';
std::cerr << std::flush;
}
template <typename T, typename... Args>
void deb(const char *delim, std::deque<std::string> v, T a, Args... args) {
std::cerr << v[0].substr(v[0][0] == ' ', v[0].length()) << " = " << a
<< delim;
v.pop_front();
deb(delim, std::move(v), args...);
}
template <typename... Args>
auto wrap(std::deque<std::string> v, Args... args) {
auto f = [=](const char *delim = "\n") { deb(delim, v, args...); };
return Debug<decltype(f)>(f);
}
}
#define debug(args...) ::detail::wrap(::detail::split(#args, ','), args)
#ifdef USING_BOOST
#include <boost/math/common_factor.hpp>
#include <boost/range.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/algorithm_ext.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/numeric.hpp>
inline auto rep(int begin, int end) {
if (begin > end) {
return boost::irange(0, 0);
} else {
return boost::irange(begin, end);
}
}
inline auto rep(int begin, int end, int step) {
if ((step > 0 && begin > end) || (step < 0 && begin < end)) {
return boost::irange(0, 0, step);
} else {
return boost::irange(begin, end, step);
}
}
#endif
#ifdef USING_NAMESPACE
using namespace std;
#ifdef USING_BOOST
using namespace boost;
using namespace boost::adaptors;
#endif
#endif
/*** Template End ***/
int main() {
int n;
in(n);
auto c = vin<int>(n);
for (int &x : c) {
x--;
}
int ans = 0;
for (int i : rep(0, n)) {
vector<int> d(n);
for (int j : rep(0, n)) {
d[j] = abs(c[j] - j);
}
auto idx = max_element(d) - d.begin();
int k = c[idx];
out(idx, k);
if (k == idx) {
break;
} else {
c.erase(c.begin() + idx);
c.insert(c.begin() + k, k);
}
ans++;
}
out(ans);
}
Submission Info
Submission Time |
|
Task |
D - トランプ挿入ソート |
User |
mino |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
5726 Byte |
Status |
WA |
Exec Time |
2103 ms |
Memory |
768 KB |
Judge Result
Set Name |
smallA |
smallB |
all |
Score / Max Score |
0 / 10 |
0 / 40 |
0 / 50 |
Status |
|
|
|
Set Name |
Test Cases |
smallA |
test_01_ABC.txt, test_04_ABC.txt, test_07_ABC.txt, test_10_ABC.txt, test_13_ABC.txt, test_16_ABC.txt, test_19_ABC.txt, test_22_ABC.txt, test_25_ABC.txt, test_28_ABC.txt, test_31_ABC.txt, test_32_ABC.txt, test_35_ABC.txt, test_38_ABC.txt, test_41_ABC.txt, test_44_ABC.txt, test_47_ABC.txt, test_50_ABC.txt, test_53_ABC.txt |
smallB |
test_01_ABC.txt, test_02_AB.txt, test_04_ABC.txt, test_05_AB.txt, test_07_ABC.txt, test_08_AB.txt, test_10_ABC.txt, test_11_AB.txt, test_13_ABC.txt, test_14_AB.txt, test_16_ABC.txt, test_17_AB.txt, test_19_ABC.txt, test_20_AB.txt, test_22_ABC.txt, test_23_AB.txt, test_25_ABC.txt, test_26_AB.txt, test_28_ABC.txt, test_29_AB.txt, test_31_ABC.txt, test_32_ABC.txt, test_33_AB.txt, test_35_ABC.txt, test_36_AB.txt, test_38_ABC.txt, test_39_AB.txt, test_41_ABC.txt, test_42_AB.txt, test_44_ABC.txt, test_45_AB.txt, test_47_ABC.txt, test_48_AB.txt, test_50_ABC.txt, test_51_AB.txt, test_53_ABC.txt, test_54_AB.txt |
all |
test_01_ABC.txt, test_02_AB.txt, test_03_A.txt, test_04_ABC.txt, test_05_AB.txt, test_06_A.txt, test_07_ABC.txt, test_08_AB.txt, test_09_A.txt, test_10_ABC.txt, test_11_AB.txt, test_12_A.txt, test_13_ABC.txt, test_14_AB.txt, test_15_A.txt, test_16_ABC.txt, test_17_AB.txt, test_18_A.txt, test_19_ABC.txt, test_20_AB.txt, test_21_A.txt, test_22_ABC.txt, test_23_AB.txt, test_24_A.txt, test_25_ABC.txt, test_26_AB.txt, test_27_A.txt, test_28_ABC.txt, test_29_AB.txt, test_30_A.txt, test_31_ABC.txt, test_32_ABC.txt, test_33_AB.txt, test_34_A.txt, test_35_ABC.txt, test_36_AB.txt, test_37_A.txt, test_38_ABC.txt, test_39_AB.txt, test_40_A.txt, test_41_ABC.txt, test_42_AB.txt, test_43_A.txt, test_44_ABC.txt, test_45_AB.txt, test_46_A.txt, test_47_ABC.txt, test_48_AB.txt, test_49_A.txt, test_50_ABC.txt, test_51_AB.txt, test_52_A.txt, test_53_ABC.txt, test_54_AB.txt, test_55_A.txt |
Case Name |
Status |
Exec Time |
Memory |
sample_01.txt |
WA |
1 ms |
256 KB |
sample_02.txt |
WA |
1 ms |
256 KB |
sample_03.txt |
WA |
1 ms |
256 KB |
test_01_ABC.txt |
WA |
1 ms |
256 KB |
test_02_AB.txt |
WA |
8 ms |
256 KB |
test_03_A.txt |
TLE |
2103 ms |
640 KB |
test_04_ABC.txt |
WA |
1 ms |
256 KB |
test_05_AB.txt |
WA |
6 ms |
256 KB |
test_06_A.txt |
WA |
49 ms |
256 KB |
test_07_ABC.txt |
WA |
1 ms |
256 KB |
test_08_AB.txt |
WA |
8 ms |
256 KB |
test_09_A.txt |
TLE |
2103 ms |
768 KB |
test_10_ABC.txt |
WA |
1 ms |
256 KB |
test_11_AB.txt |
WA |
3 ms |
256 KB |
test_12_A.txt |
WA |
1388 ms |
512 KB |
test_13_ABC.txt |
WA |
1 ms |
256 KB |
test_14_AB.txt |
WA |
8 ms |
256 KB |
test_15_A.txt |
TLE |
2103 ms |
640 KB |
test_16_ABC.txt |
WA |
1 ms |
256 KB |
test_17_AB.txt |
WA |
4 ms |
256 KB |
test_18_A.txt |
WA |
23 ms |
256 KB |
test_19_ABC.txt |
WA |
1 ms |
256 KB |
test_20_AB.txt |
WA |
8 ms |
256 KB |
test_21_A.txt |
TLE |
2103 ms |
640 KB |
test_22_ABC.txt |
WA |
1 ms |
256 KB |
test_23_AB.txt |
WA |
6 ms |
256 KB |
test_24_A.txt |
TLE |
2103 ms |
640 KB |
test_25_ABC.txt |
WA |
1 ms |
256 KB |
test_26_AB.txt |
WA |
8 ms |
256 KB |
test_27_A.txt |
TLE |
2103 ms |
640 KB |
test_28_ABC.txt |
WA |
1 ms |
256 KB |
test_29_AB.txt |
WA |
7 ms |
256 KB |
test_30_A.txt |
TLE |
2103 ms |
640 KB |
test_31_ABC.txt |
WA |
1 ms |
256 KB |
test_32_ABC.txt |
WA |
1 ms |
256 KB |
test_33_AB.txt |
WA |
1 ms |
256 KB |
test_34_A.txt |
WA |
4 ms |
512 KB |
test_35_ABC.txt |
WA |
1 ms |
256 KB |
test_36_AB.txt |
WA |
1 ms |
256 KB |
test_37_A.txt |
WA |
2 ms |
256 KB |
test_38_ABC.txt |
WA |
1 ms |
256 KB |
test_39_AB.txt |
WA |
8 ms |
256 KB |
test_40_A.txt |
TLE |
2103 ms |
640 KB |
test_41_ABC.txt |
WA |
1 ms |
256 KB |
test_42_AB.txt |
WA |
4 ms |
256 KB |
test_43_A.txt |
WA |
61 ms |
256 KB |
test_44_ABC.txt |
WA |
1 ms |
256 KB |
test_45_AB.txt |
WA |
4 ms |
256 KB |
test_46_A.txt |
WA |
1818 ms |
640 KB |
test_47_ABC.txt |
WA |
1 ms |
256 KB |
test_48_AB.txt |
WA |
1 ms |
256 KB |
test_49_A.txt |
WA |
33 ms |
256 KB |
test_50_ABC.txt |
WA |
1 ms |
256 KB |
test_51_AB.txt |
WA |
8 ms |
256 KB |
test_52_A.txt |
TLE |
2103 ms |
640 KB |
test_53_ABC.txt |
WA |
1 ms |
256 KB |
test_54_AB.txt |
WA |
2 ms |
256 KB |
test_55_A.txt |
TLE |
2103 ms |
640 KB |