QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#536980#7414. Easy WinXiaohubaAC ✓129ms3692kbC++232.9kb2024-08-29 18:26:442024-08-29 18:26:44

Judging History

你现在查看的是最新测评结果

  • [2024-08-29 18:26:44]
  • 评测
  • 测评结果:AC
  • 用时:129ms
  • 内存:3692kb
  • [2024-08-29 18:26:44]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

// #define LOCK_GETCHAR
#define USE_INT_128

#if __cplusplus < 201400
#warning "Please use c++14 or higher."
#define CONSTEXPR_FUNC
#define ENABLE_IF_INT
#else
#define CONSTEXPR_FUNC constexpr
#define ENABLE_IF_INT , enable_if_t<_is_integer<T>, int> = 0
template <class T> constexpr bool _is_integer = numeric_limits<T>::is_integer;
template <> constexpr bool _is_integer<bool> = false;
template <> constexpr bool _is_integer<char> = false;
#ifdef USE_INT_128
template <> constexpr bool _is_integer<__int128> = true;
template <> constexpr bool _is_integer<__uint128_t> = true;
#endif
#endif

#if !defined(_WIN32) && !defined(LOCK_GETCHAR)
#define getchar getchar_unlocked
#endif

#define il inline
#define mkp make_pair
#define fi first
#define se second
#define _loop_i_t(j, k) make_signed_t<decltype((j) - (k))>
#define For(i, j, k) for (_loop_i_t(j, k) i = (j); i <= (k); ++i) // NOLINT
#define ForDown(i, j, k)                                                       \
  for (_loop_i_t(j, k) i = (j); i >= decltype(i)(k); --i) // NOLINT
#define eb emplace_back
#ifndef ONLINE_JUDGE
#define FileIO(filename)                                                       \
  freopen(filename ".in", "r", stdin);                                         \
  freopen(filename ".out", "w", stdout)
#else
#define FileIO(filename) void(0)
#endif

using ll = long long;
using uint = unsigned int;
using ull = unsigned long long;
using db = double;
using ldb = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#ifdef USE_INT_128
using lll = __int128_t;
using ulll = __uint128_t;
#endif

// clang-format off
CONSTEXPR_FUNC il ll qpow(ll x, ull y, ll mod){ ll ans = 1; x %= mod; while (y) { if (y & 1) (ans *= x) %= mod; (x *= x) %= mod; y >>= 1; } return ans; }
template<typename T> CONSTEXPR_FUNC il void cmin(T & x, const T &y){ x = min(x, y); }
template<typename T> CONSTEXPR_FUNC il void cmax(T & x, const T &y){ x = max(x, y); }
template<typename T ENABLE_IF_INT> il void read(T &x){ x = 0; int f = 1; int c = getchar(); while (!isdigit(c)) { if (c == '-') f = -1; c = getchar(); } while (isdigit(c)) { x = x * 10 + c - '0'; c = getchar(); } x *= f; }
template<typename T, typename ... Args> il void read(T &x, Args &... y){ read(x), read(y...); }
// clang-format on

// File head end

namespace {
// constexpr ll MAXN = ...;
int n, q, W[128];
lll lb[128];
void ins(lll val, int wi) {
  ForDown(i, 124, 0) if (val >> i & 1) {
    if (!lb[i])
      return lb[i] = val, W[i] = wi, void();
    if (W[i] < wi)
      swap(lb[i], val), swap(W[i], wi);
    val ^= lb[i];
  }
}
il void Main() {
  read(n, q);
  while (q--) {
    int u, v, w;
    lll a;
    read(u, v, a, w), a |= lll(1) << (u + 60) | lll(1) << (v + 60);
    ins(a, w);
    ll ans = 0;
    For(i, 0, 124) ans += W[i];
    cout << ans << '\n';
  }
}
} // namespace

signed main() { return Main(), 0; }

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3684kb

input:

3 3
1 2 0 1
2 3 0 1
3 1 0 2

output:

1
2
3

result:

ok 3 number(s): "1 2 3"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3664kb

input:

6 6
1 2 1 1
2 3 1 2
3 4 1 3
4 1 1 4
5 6 1 2
6 5 1 1

output:

1
3
6
9
11
11

result:

ok 6 numbers

Test #3:

score: 0
Accepted
time: 0ms
memory: 3692kb

input:

5 5
1 2 0 1
2 3 1 1
3 4 2 3
4 5 4 9
5 1 7 29

output:

1
2
5
14
42

result:

ok 5 number(s): "1 2 5 14 42"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

5 1
3 5 35 35

output:

35

result:

ok 1 number(s): "35"

Test #5:

score: 0
Accepted
time: 122ms
memory: 3688kb

input:

64 200000
55 54 912342934380219152 5847261
9 37 432945431905386803 885970155
4 20 593333932581756491 458230787
64 16 494637219061286873 834276424
24 40 562003837727105546 576168413
34 42 595185183345681548 670023013
64 8 1115973803822151574 229135927
37 46 265620631240597434 513898966
40 57 34467276...

output:

5847261
891817416
1350048203
2184324627
2760493040
3430516053
3659651980
4173550946
4262856902
5021500912
5816668514
6132845214
6848399164
7172854021
7816813583
7824483154
8096127231
8987489763
9121935469
9985538162
10349656214
11255266117
11277439861
11823233255
12681650803
13063776488
13384711767
...

result:

ok 200000 numbers

Test #6:

score: 0
Accepted
time: 122ms
memory: 3604kb

input:

64 200000
1 12 286246842922607163 4332
62 8 856926090238618997 154305812
47 1 728448197469630668 603526763
61 26 440095169435429855 401569467
40 11 878032489352428411 707427237
4 51 184039950855837718 988911395
33 25 899195620049058582 302627192
25 51 975158729522648315 703919078
13 52 1255835680254...

output:

4332
154310144
757836907
1159406374
1866833611
2855745006
3158372198
3862291276
4177156896
4177191684
4293823320
4293887927
4405373394
4950885447
4950959336
4964633252
5483997426
5484104090
5889588923
6378634270
6378748296
6777287763
7429406416
8038770570
8038946362
8938771431
9509756408
10124884616...

result:

ok 200000 numbers

Test #7:

score: 0
Accepted
time: 125ms
memory: 3592kb

input:

64 200000
49 8 274726518388334342 17137
21 20 548824895341420802 519378885
58 15 61850028464682397 426238305
5 8 362803476167911979 31350
26 62 992761119401077269 569554716
9 62 457151622380128144 34830
17 51 800389154683469460 597215235
13 23 613846838507137884 39412
48 39 14693317947303944 42796
2...

output:

17137
519396022
945634327
945665677
1515220393
1515255223
2112470458
2112509870
2112552666
2112615774
2854732800
2854812818
3083189926
3083290877
3757654589
3757762737
3757882391
3758020396
4007157087
4668813594
5539744450
5539887004
5540057538
5540234464
6484884285
6485079324
7422703553
7422904944
...

result:

ok 200000 numbers

Test #8:

score: 0
Accepted
time: 114ms
memory: 3528kb

input:

64 200000
60 23 540722506957170758 2165
46 23 542244526237492688 4735
46 7 252565778045011254 633068870
40 42 547234488737951143 8671
53 19 521159549575389335 83512050
25 16 573490928877709644 12159
55 41 553700972696257257 16607
21 44 1138854834131855655 16702
9 46 341299457815786859 23836
23 32 54...

output:

2165
6900
633075770
633084441
716596491
716608650
716625257
716641959
716665795
716698902
1068786839
1068821859
1614262464
1614303526
2204075219
2204119178
2219480298
2219525026
2219570423
2219627957
2219690044
2756527581
2756594136
2756660848
2756731504
3204881526
3204968581
3205057654
3205149557
3...

result:

ok 200000 numbers

Test #9:

score: 0
Accepted
time: 129ms
memory: 3608kb

input:

64 200000
53 56 632454438630714126 240
41 19 1102328253181696484 6581
3 40 866610923231891100 14477
9 49 87724750373351923 21949
27 20 308253103263652268 28706
12 8 849933349622046903 36034
45 43 67413645493546289 39732
64 60 129312689005781742 39995
44 33 329954194867708120 43074
5 64 8933292993952...

output:

240
6821
21298
43247
71953
107987
147719
187714
230788
276676
328773
382443
440464
516571
593517
672669
758846
853194
961660
1087011
1212436
1339129
1468120
1600768
1746123
1897186
2056416
2216711
2377821
2541461
2706530
2888953
3073002
3260019
3450381
3648375
3846413
4051510
4264111
4480794
4700220...

result:

ok 200000 numbers