提出 #74722401


ソースコード 拡げる

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

#ifdef LOCAL
#include "../../Templates/C++/debug.h"
#else
#define debug(...) 42
#endif

typedef long long ll;
typedef long double ld;
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pl> vpl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;

template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define lso(s) ((s) & -(s))
int lg(ll s) { return s ? __builtin_clzll(1) - __builtin_clzll(s) : -1; }//lg(1)=0, lg(2)=1, lg(3)=1, lg(4)=2, ...
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()

const int MOD = 998244353;
const double EPS = 1e-9;
const char nl = '\n';
const int INF = 1e9;
const ll INFL = 4e18;
ll gcd(ll a,ll b) { if (b==0) return a; return gcd(b, a%b); }
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll floor(ll a, ll b) { return a / b - (a % b < 0); }
ll ceil(ll a, ll b) { return a / b + (a % b > 0); }

template<typename T>
istream& operator>>(istream& in, vector<T> &vec){
    for(auto &x : vec){
        in>>x;
    }
    return in;
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        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);
    }
};

mt19937_64 rng(10);//rng(chrono::steady_clock::now().time_since_epoch().count());
ll gen() {
	ll x = 0;
	while(x == 0)
		x = rng() % MOD;
	return x;
}

struct mint {
  ll x;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint& operator+=(const mint a) {if ((x += a.x) >= MOD) x -= MOD;return *this;}
  mint& operator-=(const mint a) {if ((x += MOD-a.x) >= MOD) x -= MOD;return *this;}
  mint& operator*=(const mint a) {(x *= a.x) %= MOD;return *this;}
  mint operator+(const mint a) const {mint res(*this);return res+=a;}
  mint operator-(const mint a) const {mint res(*this);return res-=a;}
  mint operator*(const mint a) const {mint res(*this);return res*=a;}
  mint pow(ll b) const {
    mint res(1), a(*this);
    while (b) {
      if (b & 1) res *= a;
      a *= a;
      b >>= 1;
    }
    return res;
  }
  // for prime MOD
  mint inv() const {return pow(MOD-2);}
  mint& operator/=(const mint a) {return (*this) *= a.inv();}
  mint operator/(const mint a) const {mint res(*this);return res/=a;}
};
ostream& operator<<(ostream& os, const mint& a) {os << a.x; return os;}

const int blk = 150;

void solve() {
    int N; cin >> N;
    int M; cin >> M;
    vi a(N); cin >> a;
    vector<vector<array<int, 2>>> ints(blk + 1);
    map<int, vector<array<int, 2>>, greater<>> m;
    if(M + 1 > blk) m[M + 1].pb({0, M + 1});
    else ints[M + 1].pb({0, M + 1});
    auto add = [&](int x, int y) {
        if(y - x > blk) m[y - x].pb({x, y});
        else ints[y - x].pb({x, y});
    };
    debug(ints, m);
    for(auto x : a) {
        for(int i = x + 1; i <= blk; i++) {
            for(auto[a, b] : ints[i]) {
                add(a, a + x);
                add(a + x, b);
            }
            ints[i].resize(0);
        }
        vector<array<int, 2>> upd;
        while(sz(m) && m.begin()->first >= x + 1) {
            auto[val, ints] = *m.begin();
            m.erase(m.begin());
            for(auto[a, b] : ints) {
                upd.pb({a, a + x});
                upd.pb({a + x, b});
            }
        }
        // debug(upd);
        for(auto[a, b] : upd) add(a, b);
        // debug(x, ints, m);
    }

    vi ans(M + 1);
    for(auto& x : ints) {
        for(auto[a, b] : x) {
            for(int i = a; i < b; i++) ans[i] = i - a;
        }
    }
    for(auto&[y, x] : m) {
        for(auto[a, b] : x) {
            for(int i = a; i < b; i++) ans[i] = i - a;
        }
    }
    // debug(ans);
    ll tot = 0;
    for(int i = 1; i <= M; i++) tot ^= 1LL * i * (i - ans[i]);
    cout << tot << nl;

}


int main() {
    //魔法はイメージの世界
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int T = 1;
    cin >> T;
    while(T--) {
        solve();
    }
	return 0;
}

提出情報

提出日時
問題 D - Greedy Customer
ユーザ YuukiS18
言語 C++23 (GCC 15.2.0)
得点 700
コード長 4755 Byte
結果 AC
実行時間 1745 ms
メモリ 1012108 KiB

コンパイルエラー

./Main.cpp: In function 'void solve()':
./Main.cpp:7:20: warning: statement has no effect [-Wunused-value]
    7 | #define debug(...) 42
      |                    ^~
./Main.cpp:119:5: note: in expansion of macro 'debug'
  119 |     debug(ints, m);
      |     ^~~~~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 700 / 700
結果
AC × 1
AC × 81
セット名 テストケース
Sample 00_sample_00.txt
All 00_sample_00.txt, 01_handmade_00.txt, 01_handmade_01.txt, 01_handmade_02.txt, 01_handmade_03.txt, 01_handmade_04.txt, 01_handmade_05.txt, 01_handmade_06.txt, 01_handmade_07.txt, 01_handmade_08.txt, 01_handmade_09.txt, 01_handmade_10.txt, 01_handmade_11.txt, 01_handmade_12.txt, 01_handmade_13.txt, 01_handmade_14.txt, 01_handmade_15.txt, 01_handmade_16.txt, 01_handmade_17.txt, 01_handmade_18.txt, 01_handmade_19.txt, 01_handmade_20.txt, 01_handmade_21.txt, 01_handmade_22.txt, 01_handmade_23.txt, 01_handmade_24.txt, 01_handmade_25.txt, 01_handmade_26.txt, 01_handmade_27.txt, 01_handmade_28.txt, 01_handmade_29.txt, 01_handmade_30.txt, 01_handmade_31.txt, 01_handmade_32.txt, 01_handmade_33.txt, 01_handmade_34.txt, 01_handmade_35.txt, 01_handmade_36.txt, 01_handmade_37.txt, 01_handmade_38.txt, 01_handmade_39.txt, 01_handmade_40.txt, 01_handmade_41.txt, 01_handmade_42.txt, 01_handmade_43.txt, 01_handmade_44.txt, 01_handmade_45.txt, 01_handmade_46.txt, 01_handmade_47.txt, 01_handmade_48.txt, 01_handmade_49.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 02_random_06.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt, 02_random_10.txt, 02_random_11.txt, 02_random_12.txt, 02_random_13.txt, 02_random_14.txt, 02_random_15.txt, 02_random_16.txt, 02_random_17.txt, 02_random_18.txt, 02_random_19.txt, 02_random_20.txt, 02_random_21.txt, 02_random_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
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 1 ms 3464 KiB
01_handmade_00.txt AC 264 ms 204736 KiB
01_handmade_01.txt AC 136 ms 200660 KiB
01_handmade_02.txt AC 121 ms 199844 KiB
01_handmade_03.txt AC 1102 ms 601940 KiB
01_handmade_04.txt AC 121 ms 198612 KiB
01_handmade_05.txt AC 1221 ms 871188 KiB
01_handmade_06.txt AC 866 ms 676964 KiB
01_handmade_07.txt AC 279 ms 206600 KiB
01_handmade_08.txt AC 268 ms 208500 KiB
01_handmade_09.txt AC 271 ms 216452 KiB
01_handmade_10.txt AC 200 ms 202788 KiB
01_handmade_11.txt AC 1195 ms 698660 KiB
01_handmade_12.txt AC 124 ms 199764 KiB
01_handmade_13.txt AC 1095 ms 601796 KiB
01_handmade_14.txt AC 142 ms 201764 KiB
01_handmade_15.txt AC 1015 ms 591368 KiB
01_handmade_16.txt AC 801 ms 591336 KiB
01_handmade_17.txt AC 1120 ms 1012100 KiB
01_handmade_18.txt AC 722 ms 658980 KiB
01_handmade_19.txt AC 1106 ms 1012108 KiB
01_handmade_20.txt AC 1064 ms 591504 KiB
01_handmade_21.txt AC 1116 ms 591700 KiB
01_handmade_22.txt AC 1124 ms 593404 KiB
01_handmade_23.txt AC 1269 ms 614816 KiB
01_handmade_24.txt AC 885 ms 591332 KiB
01_handmade_25.txt AC 870 ms 592380 KiB
01_handmade_26.txt AC 882 ms 592156 KiB
01_handmade_27.txt AC 1225 ms 958660 KiB
01_handmade_28.txt AC 310 ms 243796 KiB
01_handmade_29.txt AC 737 ms 595868 KiB
01_handmade_30.txt AC 1161 ms 654036 KiB
01_handmade_31.txt AC 1078 ms 600272 KiB
01_handmade_32.txt AC 1088 ms 599580 KiB
01_handmade_33.txt AC 1081 ms 599200 KiB
01_handmade_34.txt AC 1089 ms 599228 KiB
01_handmade_35.txt AC 1088 ms 599060 KiB
01_handmade_36.txt AC 1094 ms 599184 KiB
01_handmade_37.txt AC 1095 ms 598672 KiB
01_handmade_38.txt AC 1094 ms 598408 KiB
01_handmade_39.txt AC 1110 ms 597332 KiB
01_handmade_40.txt AC 1097 ms 597776 KiB
01_handmade_41.txt AC 917 ms 592508 KiB
01_handmade_42.txt AC 924 ms 591960 KiB
01_handmade_43.txt AC 1096 ms 644372 KiB
01_handmade_44.txt AC 1092 ms 614772 KiB
01_handmade_45.txt AC 1092 ms 618964 KiB
01_handmade_46.txt AC 889 ms 591580 KiB
01_handmade_47.txt AC 880 ms 591428 KiB
01_handmade_48.txt AC 863 ms 592236 KiB
01_handmade_49.txt AC 1745 ms 591348 KiB
02_random_00.txt AC 55 ms 24996 KiB
02_random_01.txt AC 55 ms 24556 KiB
02_random_02.txt AC 56 ms 24896 KiB
02_random_03.txt AC 50 ms 24020 KiB
02_random_04.txt AC 145 ms 202264 KiB
02_random_05.txt AC 135 ms 200840 KiB
02_random_06.txt AC 132 ms 200208 KiB
02_random_07.txt AC 129 ms 200264 KiB
02_random_08.txt AC 169 ms 207152 KiB
02_random_09.txt AC 132 ms 200748 KiB
02_random_10.txt AC 143 ms 203756 KiB
02_random_11.txt AC 151 ms 202528 KiB
02_random_12.txt AC 144 ms 202156 KiB
02_random_13.txt AC 122 ms 198948 KiB
02_random_14.txt AC 232 ms 208640 KiB
02_random_15.txt AC 299 ms 274152 KiB
02_random_16.txt AC 858 ms 611484 KiB
02_random_17.txt AC 1073 ms 778824 KiB
02_random_18.txt AC 27 ms 32704 KiB
02_random_19.txt AC 51 ms 66512 KiB
02_random_20.txt AC 154 ms 203196 KiB
02_random_21.txt AC 178 ms 214688 KiB
02_random_22.txt AC 176 ms 210016 KiB
02_random_23.txt AC 171 ms 206496 KiB
02_random_24.txt AC 882 ms 591936 KiB
02_random_25.txt AC 818 ms 601184 KiB
02_random_26.txt AC 867 ms 610300 KiB
02_random_27.txt AC 888 ms 592312 KiB
02_random_28.txt AC 881 ms 591860 KiB
02_random_29.txt AC 884 ms 591976 KiB