結果

問題 No.490 yukiソート
ユーザー MaxMellonMaxMellon
提出日時 2017-07-02 14:46:35
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 737 bytes
コンパイル時間 973 ms
コンパイル使用メモリ 64,812 KB
実行使用メモリ 71,756 KB
最終ジャッジ日時 2024-04-15 12:00:21
合計ジャッジ時間 6,198 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>

using namespace std;

bool my_swap(int arr[], int p1, int p2);
bool my_order(int arr[], int p1, int p2);

int main()
{
  int n = 0;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }

  for (int i = 0; i < 2 * n - 3; i++) {
    for (int j = 0; j < i; j++) {
      for (int k = 0; k < j; k++) {
        if (j + k != i) continue;
        (my_order(arr, j, k) == true) && (my_swap(arr, j, k));
      }
    }
  }

  for (int i = 0; i < n; i++) {
    cout << arr[i] << " ";
  }
  cout << endl;
}

bool my_order(int arr[], int p1, int p2) {
  return arr[p1] <= arr[p2];
}

bool my_swap(int arr[], int p1, int p2) {
  int tmp = arr[p1];
  arr[p1] = arr[p2];
  arr[p2] = tmp;
  return true;
}

0