結果

問題 No.2870 Dice Making
ユーザー C++ C++
提出日時 2024-09-06 21:23:32
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 12,063 bytes
コンパイル時間 4,361 ms
コンパイル使用メモリ 279,128 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-06 21:23:39
合計ジャッジ時間 5,766 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// #pragma comment(linker, "/STACK:1073741824")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#pragma region Macros
#if __has_include("debug.h")
#include "debug.h"
#else
#define print__(...) 10
#endif
using ll = long long;
using u64 = unsigned long long;
using u32 = unsigned int;
using ld = long double;
using cd = complex<double>;
#define _overload4(_1,_2,_3,_4,name,...) name
#define _overload3(_1,_2,_3,name,...) name
#define _rep1(n) for(ll i=0;i<n;++i)
#define _rep2(i,n) for(ll i=0;i<n;++i)
#define _rep3(i,a,b) for(ll i=a;i<b;++i)
#define _rep4(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) _overload4(__VA_ARGS__,_rep4,_rep3,_rep2,_rep1)(__VA_ARGS__)
#define _rrep1(n) for(ll i=n-1;i>=0;i--)
#define _rrep2(i,n) for(ll i=n-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=b-1;i>=a;i--)
#define _rrep4(i,a,b,c) for(ll i=a+(b-a-1)/c*c;i>=a;i-=c)
#define rrep(...) _overload4(__VA_ARGS__,_rrep4,_rrep3,_rrep2,_rrep1)(__VA_ARGS__)
#define each(i,a) for(auto &i:a)
#define sum(...) accumulate(range(__VA_ARGS__),0LL)
#define dsum(...) accumulate(range(__VA_ARGS__),double(0))
#define _range(i) (i).begin(),(i).end()
#define _range2(i,k) (i).begin(),(i).begin()+k
#define _range3(i,a,b) (i).begin()+a,(i).begin()+b
#define range(...) _overload3(__VA_ARGS__,_range3,_range2,_range)(__VA_ARGS__)
#define _rrange(i) (i).rbegin(),(i).rend()
#define _rrange2(i,k) (i).rbegin(),(i).rbegin()+k
#define _rrange3(i,a,b) (i).rbegin()+a,(i).rbegin()+b
#define rrange(...) _overload3(__VA_ARGS__,_rrange3,_rrange2,_rrange)(__VA_ARGS__)
#define MIN(...) min_element(range(__VA_ARGS__))
#define MAX(...) max_element(range(__VA_ARGS__))
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define ppf pop_front
#define len(c) static_cast<ll>(c.size()) 
#define fi first
#define se second
#define elif else if
#define unless(a) if(!(a))
#define mp make_pair
#define mt make_tuple
#define unique(c) sort(range(c)), c.erase(unique(range(c)), c.end());
#define ook order_of_key // order_of_key (k) : Number of items strictly smaller than k .
#define fbo find_by_order // find_by_order(k) : K-th element in a set (counting from zero).
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using vc = vector<T>;
template<typename T> using vvc = vector<vc<T>>;
template<typename T> using vvvc = vector<vvc<T>>;
template<typename T> using vvvvc = vector<vvvc<T>>;
template<class T> using max_heap = priority_queue<T>;
template<class T> using min_heap = priority_queue<T, vc<T>, greater<T>>;
template<class T> bool chmin(T& a, const T& b){ if(a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, const T& b){ if(a < b) {a = b; return true;} return false;}  

template<class T> struct infinity{ static constexpr T value = numeric_limits<T>::max() / 2; static constexpr T mvalue = numeric_limits<T>::min() / 2; static constexpr T max = numeric_limits<T>::max(); static constexpr T min = numeric_limits<T>::min(); };

#if __cpp_variable_templates >= 201304L
template<class T> constexpr T INF = infinity<T>::value;
#endif

const ll inf = infinity<ll>::value;
const ld EPS = 1e-8;
constexpr ld PI = 3.1415926535897932384626;

// lower bound
template <class T> int arglb(const std::vector<T> &v, const T &x) { return std::distance(v.begin(), std::lower_bound(range(v), x)); }
// upper bound
template <class T> int argub(const std::vector<T> &v, const T &x) { return std::distance(v.begin(), std::upper_bound(range(v), x)); }

template<class T> T binpow(T x, T n){T res = T(1); while(n){if(n & 1) res *= x; x *= x; n >>= 1;} return res;}
template<class T> T modpow(T x, T n, T mod){T res = T(1); while(n){if(n & 1) (res *= x) %= mod; (x *= x) %= mod; n >>= 1;} return res;}
template<class T> T gcd(T a, T b){ return b == T(0) ? a : gcd(b, a % b);}
template<class T> T lcm(T a, T b){ return a / gcd<T>(a, b) * b;}
template <typename T> T POPF(deque<T> &que) { T a = que.front(); que.ppf(); return a; }
template <typename T> T POPB(deque<T> &que) { T a = que.back(); que.ppb(); return a; }
template <typename T> T POP(max_heap<T> &que) { T a = que.top(); que.pop(); return a; }
template <typename T> T POP(min_heap<T> &que) { T a = que.top(); que.pop(); return a; }
template <typename T> T POP(queue<T> &que) { T a = que.front(); que.pop(); return a; }
template <typename T> T POP(vc<T> &que) { T a = que.back(); que.ppb(); return a; }

inline Pl extGCD(ll a, ll b) { const ll n = a, m = b; ll x = 1, y = 0, u = 0, v = 1; ll t; while (b) { t = a / b; std::swap(a -= t * b, b); std::swap(x -= t * u, u); std::swap(y -= t * v, v); } if (x < 0) x += m, y -= n;  return {x, y}; }

// Print
void print() { cout << "\n"; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) { cout << head; if (sizeof...(Tail)) cout << " "; print(forward<Tail>(tail)...); }

// double input seems slow on CF
void read(double& x) { string t; cin >> t; x = stod(t); } 
void read(long double& x) { string t; cin >> t; x = stold(t); }
template<class T> void read(T& x) { cin >> x; }
template<class Arg, class... Args> void read(Arg& first, Args&... rest) {  read(first); read(rest...); }

auto get_ans(bool cond = true, string yes = "YES", string no = "NO"){cout << (cond ? yes : no) << '\n';}
template<class T> void dump(T print_dump_val, bool _exit = false, bool _nendl = false){ cout << print_dump_val; if(_exit) exit(0); if(_nendl) cout << '\n'; return; }

template <class T> auto vect(const T& v, int n) { return vector<T>(n, v); }
template <class T, class... D> auto vect(const T& v, int n, D... m) { return vector<decltype(vect(v, m...))>(n, vect(v, m...)); }

template<typename T_container, typename T = typename std::enable_if<!std::is_same<T_container, std::string>::value, typename T_container::value_type>::type>  std::istream& operator >> (std::istream &is, T_container &v) {  for(T &x : v) {is >> x;} return is; }
template <class T, class U> istream &operator>>(istream &is, std::pair<T, U> &pa) { is >> pa.first >> pa.second ; return is; }
template <class... T> std::istream &operator>>(std::istream &is, std::tuple<T...> &tpl) { std::apply([&is](auto &&... args) { ((is >> args), ...);}, tpl); return is; }
template<class T> T get(){ T t; cin >> t; return t;}

#ifdef LOCAL
template <class T> ostream &operator<<(ostream &os, const std::vector<T> &vec) { for (auto v : vec) os << v << ' '; return os; }
#endif
template <class T> ostream &operator<<(ostream &os, const std::pair<T, T> &p) { os << p.fi << ' ' << p.se; return os; }
template <class... T> ostream &operator<<(ostream &os, const std::tuple<T...> &tpl) { std::apply([&os](auto &&... args) { ((os << args << ' '), ...);}, tpl); return os; }

// Bit OPS
int popcnt(int x) { return __builtin_popcount(x); }
int popcnt(u32 x) { return __builtin_popcount(x); }
int popcnt(ll x) { return __builtin_popcountll(x); }
int popcnt(u64 x) { return __builtin_popcountll(x); }
int popcnt_mod_2(int x) { return __builtin_parity(x); }
int popcnt_mod_2(u32 x) { return __builtin_parity(x); }
int popcnt_mod_2(ll x) { return __builtin_parityll(x); }
int popcnt_mod_2(u64 x) { return __builtin_parityll(x); }
// (0, 1, 2, 3, 4) -> (-1, 0, 1, 1, 2)
int topbit(int x) { return (x == 0 ? -1 : 31 - __builtin_clz(x)); }
int topbit(u32 x) { return (x == 0 ? -1 : 31 - __builtin_clz(x)); }
int topbit(ll x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); }
int topbit(u64 x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); }
// (0, 1, 2, 3, 4) -> (-1, 0, 1, 0, 2)
int lowbit(int x) { return (x == 0 ? -1 : __builtin_ctz(x)); }
int lowbit(u32 x) { return (x == 0 ? -1 : __builtin_ctz(x)); }
int lowbit(ll x) { return (x == 0 ? -1 : __builtin_ctzll(x)); }
int lowbit(u64 x) { return (x == 0 ? -1 : __builtin_ctzll(x)); }

// Floor, Ceil, Divmods
template <typename T> T floor(T a, T b) { return a / b - (a % b && (a ^ b) < 0); }
template <typename T> T ceil(T x, T y) { return floor(x + y - 1, y); }
template <typename T> T bmod(T x, T y) { return x - y * floor(x, y); }
template <typename T> pair<T, T> divmod(T x, T y) { T q = floor(x, y); return {q, x - q * y}; }

// Graph 2D Dirs
constexpr Pi dx8[8] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const char dir[4] = {'D', 'R', 'U', 'L'};

// ? is -1
vc<int> s_to_vi(const string& S, char first_char){ vc<int> A(size(S)); rep(size(S)) A[i] = (S[i] != '?' ? S[i] - first_char : -1);  return A; }

// stable sort
template <typename T> vector<int> argsort(const vector<T> &A) { vector<int> ids(size(A)); iota(range(ids), 0); sort(range(ids), [&](int i, int j) { return (A[i] == A[j] ? i < j : A[i] < A[j]); }); return ids; }

// Pref SUM
template <typename T, typename U> vector<T> cumsum(vector<U> &A, bool off = 1) { int N = A.size(); vector<T> B(N + 1); rep(N) { B[i + 1] = B[i] + A[i]; } if (off == 0) B.erase(B.begin()); return B;
}

// rearrange a vector according to another vector
template <typename T> vc<T> rearrange(const vc<T> &A, const vc<int> &I) { vc<T> B(size(I)); rep(i, size(I)) B[i] = A[I[i]]; return B; }

//BinCount
vc<int> bincount(vc<int>& A, ll si){ vc<int> C(si); each(x, A) ++C[x]; return C; }

// Binary Search
template<typename F>
ll binary_search(F check, ll ok, ll ng, bool check_ok = true){ if(check_ok) assert(check(ok)); while(abs(ok - ng) > 1){ auto x = (ng + ok) / 2; tie(ok, ng) = (check(x) ? mp(x, ng) : mp(ok, x)); } return ok; }

struct custom_hash { static uint64_t splitmix64(uint64_t x) { x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); } size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); }};

// RNG
u64 RNG_64() {
  static uint64_t x_
      = uint64_t(chrono::duration_cast<chrono::nanoseconds>(
                     chrono::high_resolution_clock::now().time_since_epoch())
                     .count())
        * 10150724397891781847ULL;
  x_ ^= x_ << 7;
  return x_ ^= x_ >> 9;
}
u64 RNG(u64 lim) { return RNG_64() % lim; }
ll RNG(ll l, ll r) { return l + RNG_64() % (r - l); }

// Split string 
vc<string> split(string S, string seps = " ,"){ vc<string> res = {""}; each(s, S){ if(count(range(seps), s)) res.eb(""); else res.back() += s; } return res; }

// Y - Combinator
namespace std{
  template<class Fun>
  class y_combinator_result{
    Fun fun_;
    public:
      template<class T>
      explicit y_combinator_result(T &&fun) : fun_(std::forward<T>(fun)) {}
      template<class ...Args> decltype(auto) operator() (Args&&... args){ return fun_(std::ref(*this), std::forward<Args>(args)...);}
  };
}
template<class Fun>
decltype(auto) y_combinator(Fun&& fun){ return y_combinator_result<std::decay_t<Fun>>(std::forward<Fun>(fun));}
#pragma endregion

void run_test_cases(){
  int N, K; cin >> N >> K;
  if(N % K) return print(-1);
  vc<int> A;
  K = N / K;
  rep(K) A.eb(1);
  int num = 2;
  while(len(A) != N) A.eb(num++);
  each(x, A) cout << x << ' ';
} 

void run_case(bool testcase = false, bool query = false){
  int case_cnt = 1;
  if(testcase) cin >> case_cnt;
  for(;case_cnt--;){
    run_test_cases();
    if(!query) cout << endl;
  }
}
signed main(){
  auto start = std::chrono::system_clock::now();
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
  #endif
  cout << setprecision(16) << fixed;
  run_case();
  auto end = std::chrono::system_clock::now();
  auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(end - start);
  cerr << "Your code took " << duration.count()  << "ms" << endl;
  time_t now = time(0); // get current dat/time with respect to system  
  char* dt = ctime(&now); // convert it into string  
  cerr << "The local date and time is: " << dt; // print local date and time  
}
0