結果

問題 No.490 yukiソート
ユーザー pyraninepyranine
提出日時 2020-12-18 13:12:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 4,332 bytes
コンパイル時間 1,777 ms
コンパイル使用メモリ 171,496 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-21 09:03:45
合計ジャッジ時間 2,794 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 7 ms
5,376 KB
testcase_15 AC 7 ms
5,376 KB
testcase_16 AC 7 ms
5,376 KB
testcase_17 AC 7 ms
5,376 KB
testcase_18 AC 6 ms
5,376 KB
testcase_19 AC 7 ms
5,376 KB
testcase_20 AC 7 ms
5,376 KB
testcase_21 AC 7 ms
5,376 KB
testcase_22 AC 8 ms
5,376 KB
testcase_23 AC 7 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 1 ms
5,376 KB
testcase_30 AC 1 ms
5,376 KB
testcase_31 AC 1 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 1 ms
5,376 KB
testcase_34 AC 1 ms
5,376 KB
testcase_35 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#pragma region template
using i32 = int32_t;using i64 = int64_t;using u32 = uint32_t;using u64 = uint64_t;using f32 = float;using f64 = double;using f80 = long double;
using i128 = __int128_t;using u128 = __uint128_t;
using vi32 = vector<i32>;using vi64 = vector<i64>;using vu32 = vector<u32>;using vu64 = vector<u64>;
using vvi32 = vector<vector<int32_t>>;using vvi64 = vector<vector<int64_t>>;using vvu32 = vector<vector<uint32_t>>;using vvu64 = vector<vector<uint64_t>>;
using pi32 = pair<i32,i32>;using pi64 = pair<i64,i64>;using Pu32 = pair<u32,u32>;using Pu64 = pair<u64,u64>;
using vpi32 = vector<pi32>;using vpi64 = vector<pi64>;using vpu32 = vector<Pu32>;using vpu64 = vector<Pu64>;

#define FOR(i,a,b) for(i64 i=(a), i##_len=(b); i<i##_len; ++i)
#define RFOR(i,a,b) for(i64 i=(a), i##_len=(b); i>i##_len; --i)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(),(obj).end()
#define CLR(ar,val) memset(ar, val, sizeof(ar))
#define SZ(obj) (static_cast<i64>(obj.size()))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define PRINT(obj) std::cout<<((obj))<<std::endl;
#define PutStr(str) std::cout<<((str));
#define PutStrSp(str) std::cout<<((str))<<(" ");
#define PutStrLn(str) std::cout<<((str))<<('\n');

const i32 dx[4]={1,0,-1,0};
const i32 dy[4]={0,1,0,-1};
const int64_t INF64 = 1LL << 60;
const int32_t INF32 = 1 << 30;
const double pi = M_PI;
const double eps = 1e-10;
const int64_t Mod = 1e9+7;

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first >> p.second;return is; }
template<typename A, typename B> std::ostream &operator<<(std::ostream &os, const std::pair<A, B>& p) { os << p.first << ' ' << p.second;return os; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for(T& in : v) is >> in; return is; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::vector<T> &v) { for(i32 i = 0; i < SZ(v); i++) os << v[i] << (i+1 != SZ(v) ? " " : ""); return os; }

string i128toString(i128 value) {
  string output;
  while (output.empty() || value > 0) {
    output = (char)(value % 10 + '0') + output;
    value /= 10;
  }
  return output;
}
istream& operator>>(istream &stream, i128 &v) {
  string s;
  stream >> s;
  bool neg = false;
  if(s[0] == '-') {
    s.erase(0, 1);
    neg = true;
  }
  int len = s.length();
  v = 0;
  for(int32_t i = 0; i < len;++i) {
    v = v * 10 + s[i] - '0';
  }
  if(neg) {
    v = -v;
  }
  return stream;
}
ostream& operator<<(ostream &stream, i128 v) {
  if (v == 0) {
    stream << "0";
  }
  else {
    if(v < 0) {
      stream << "-";
      v = -v;
    }
    stream << i128toString(v);
  }
  return stream;
}
string u128toString(u128 value) {
  string output;
  while (output.empty() || value > 0) {
    output = (char)(value % 10 + '0') + output;
    value /= 10;
  }
  return output;
}
istream& operator>>(istream &stream, u128 &v) {
  string s;
  stream >> s;
  bool neg = false;
  if(s[0] == '-') {
    s.erase(0, 1);
    neg = true;
  }
  int len = s.length();
  v = 0;
  for(int32_t i = 0; i < len;++i) {
    v = v * 10 + s[i] - '0';
  }
  if(neg) {
    v = -v;
  }
  return stream;
}
ostream& operator<<(ostream &stream, u128 v) {
  if (v == 0) {
    stream << "0";
  }
  else {
    if(v < 0) {
      stream << "-";
      v = -v;
    }
    stream << u128toString(v);
  }
  return stream;
}

void Main();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  std::cout << std::fixed << std::setprecision(10);
  std::cerr << std::fixed << std::setprecision(10);
  Main();
  return 0;
}
#pragma endregion

void Main(){
  int n;
  cin >> n;
  vi32 a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 1; i < 2 * n - 3; i++) {
    for (int j = 0; j < n; j++) {
      int k = i - j;
      if (k <= j) break;
      if (k >= n) continue;
      if (a[j] > a[k]) a[j] ^= a[k] ^= a[j] ^= a[k];
    }
  }
  for (int i = 0; i < n; i++) {
    cout << a[i] << (i == (n - 1) ? '\n' : ' ');
  }
}
0