結果

問題 No.14 最小公倍数ソート
ユーザー maimai
提出日時 2017-07-07 23:37:43
言語 cLay
(20240104-1)
結果
WA  
実行時間 -
コード長 706 bytes
コンパイル時間 2,062 ms
コンパイル使用メモリ 164,912 KB
実行使用メモリ 7,948 KB
最終ジャッジ日時 2023-09-18 23:24:29
合計ジャッジ時間 8,813 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

template <typename ITER, typename ITER2>
void sort_idx_proto(const ITER begin, const ITER end, const ITER2 idxbegin, const ITER2 idxend){//, vector<int> &idxr) {
    size_t n = end - begin;
    for (auto i = idxbegin; i != idxend; ++i) *i = i-idxbegin;
    sort(idxbegin, idxend, [&begin](int l, int r) {return begin[l] < begin[r]; });
}

ll n;
ll aa[10010];
ll bb[10010];
ll gg[10010];
ll v[10010];
{
    rd(n, aa(n));
    //vector<int> v(n);
    
    rep(i, n){
        rep(j, i+1, n) gg[j] = gcd(aa[i],aa[j]);
        sort_idx_proto(gg+i, gg+n, v+i, v+n);
        rep(j, i+1, n){
            bb[j] = aa[v[j]];
        }
        rep(j, i+1, n){
            aa[j] = bb[j];
        }
    }
    wt(aa(n));
}
0