提出 #41096155


ソースコード 拡げる

#include <atcoder/all>
using namespace atcoder;
#include <bits/stdc++.h>
#include <cassert>
using namespace std;
using ll = long long;
const double pi = 3.14159265359;
const ll INF = 1LL << 60;

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

//using mint = modint998244353;
//using mint = modint1000000007;
//using mint = modint;  // mint::set_mod(p); later
//using mint = static_modint<1000000009>;

int op(int a, int b){ return min(a, b); }
int e() { return (int) 1e9; }

int main()
{
  cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);

  int N, M;
  cin >> N >> M;
  vector<int> a(N);
  for (auto &&t : a) cin >> t;

  vector<vector<int>> ps(M+1);
  segtree<int, op, e> seg(N);

  for (int i = 0; i < N; i++){
    ps[a[i]].push_back(i);
    seg.set(i, a[i]);
  }

  // 各数字が一番最後に出現する位置
  set<int> st;
  for (int i = 1; i <= M; i++){
    int j = (int) ps[i].size() - 1;
    st.insert(ps[i][j]);
  }

  // Solve
  vector<int> b;
  int pos = 0;
  for (int i = 0; i < M; i++){
    while (seg.get(*st.begin()) > M){
      st.erase(st.begin());
    }
    int r = *st.begin();
    int x = seg.prod(pos, r + 1);
    b.push_back(x);
    for (int j : ps[x]){
      seg.set(j, e());
    }
    pos = *lower_bound(ps[x].begin(), ps[x].end(), pos) + 1;
  }

  for (int x : b) cout << x << " " ;
  cout << endl;
  return 0;
}

提出情報

提出日時
問題 G - Minimum Permutation
ユーザ unnohideyuki
言語 C++ (GCC 9.2.1)
得点 600
コード長 1556 Byte
結果 AC
実行時間 224 ms
メモリ 28256 KiB

ジャッジ結果

セット名 Sample All AfterContest
得点 / 配点 0 / 0 600 / 600 0 / 0
結果
AC × 3
AC × 47
AC × 1
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_max_03.txt, 01_max_04.txt, 01_max_05.txt, 01_max_06.txt, 01_max_07.txt, 01_max_08.txt, 01_max_09.txt, 01_max_10.txt, 01_max_11.txt, 01_max_12.txt, 01_max_13.txt, 01_max_14.txt, 01_max_15.txt, 01_max_16.txt, 01_max_17.txt, 01_max_18.txt, 01_max_19.txt, 01_max_20.txt, 01_max_21.txt, 01_max_22.txt, 02_random_23.txt, 02_random_24.txt, 02_random_25.txt, 02_random_26.txt, 02_random_27.txt, 02_random_28.txt, 02_random_29.txt, 02_random_30.txt, 02_random_31.txt, 02_random_32.txt, 02_random_33.txt, 02_random_34.txt, 02_random_35.txt, 02_random_36.txt, 02_random_37.txt, 02_random_38.txt, 03_handmade_39.txt, 03_handmade_40.txt, 03_handmade_41.txt, 03_handmade_42.txt, 03_handmade_43.txt, 03_handmade_44.txt, 03_handmade_45.txt, 03_handmade_46.txt
AfterContest 04_after_contest_47.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 9 ms 3552 KiB
00_sample_01.txt AC 2 ms 3512 KiB
00_sample_02.txt AC 1 ms 3572 KiB
01_max_03.txt AC 34 ms 7240 KiB
01_max_04.txt AC 35 ms 7080 KiB
01_max_05.txt AC 34 ms 7072 KiB
01_max_06.txt AC 35 ms 7160 KiB
01_max_07.txt AC 34 ms 7196 KiB
01_max_08.txt AC 38 ms 7468 KiB
01_max_09.txt AC 41 ms 7424 KiB
01_max_10.txt AC 43 ms 7408 KiB
01_max_11.txt AC 38 ms 7424 KiB
01_max_12.txt AC 37 ms 7472 KiB
01_max_13.txt AC 107 ms 17132 KiB
01_max_14.txt AC 139 ms 17192 KiB
01_max_15.txt AC 133 ms 17132 KiB
01_max_16.txt AC 105 ms 17076 KiB
01_max_17.txt AC 113 ms 17208 KiB
01_max_18.txt AC 216 ms 28256 KiB
01_max_19.txt AC 224 ms 28228 KiB
01_max_20.txt AC 213 ms 28252 KiB
01_max_21.txt AC 214 ms 28120 KiB
01_max_22.txt AC 219 ms 28248 KiB
02_random_23.txt AC 41 ms 7144 KiB
02_random_24.txt AC 36 ms 7224 KiB
02_random_25.txt AC 31 ms 7488 KiB
02_random_26.txt AC 40 ms 7240 KiB
02_random_27.txt AC 42 ms 7204 KiB
02_random_28.txt AC 41 ms 7212 KiB
02_random_29.txt AC 29 ms 5856 KiB
02_random_30.txt AC 89 ms 13512 KiB
02_random_31.txt AC 42 ms 7464 KiB
02_random_32.txt AC 55 ms 8160 KiB
02_random_33.txt AC 77 ms 11384 KiB
02_random_34.txt AC 4 ms 3648 KiB
02_random_35.txt AC 34 ms 6988 KiB
02_random_36.txt AC 5 ms 3544 KiB
02_random_37.txt AC 70 ms 10180 KiB
02_random_38.txt AC 24 ms 5616 KiB
03_handmade_39.txt AC 2 ms 3580 KiB
03_handmade_40.txt AC 38 ms 6940 KiB
03_handmade_41.txt AC 63 ms 12176 KiB
03_handmade_42.txt AC 76 ms 16064 KiB
03_handmade_43.txt AC 109 ms 26348 KiB
03_handmade_44.txt AC 5 ms 3572 KiB
03_handmade_45.txt AC 2 ms 3516 KiB
03_handmade_46.txt AC 38 ms 7728 KiB
04_after_contest_47.txt AC 78 ms 16020 KiB