QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#449611#8598. AND Масивgreen_gold_dog#0 16ms12932kbC++201.7kb2024-06-21 15:20:292024-06-21 15:20:29

Judging History

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

  • [2024-06-21 15:20:29]
  • 评测
  • 测评结果:0
  • 用时:16ms
  • 内存:12932kb
  • [2024-06-21 15:20:29]
  • 提交

answer

//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,sse,sse2,sse3,ssse3,sse4,abm,popcnt,mmx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;
typedef long double ldb;
typedef complex<double> cd;

constexpr ll INF64 = 9'000'000'000'000'000'000, INF32 = 2'000'000'000, MOD = 1'000'000'007;
constexpr db PI = acos(-1);
constexpr bool IS_FILE = false, IS_TEST_CASES = false;

random_device rd;
mt19937 rnd32(rd());
mt19937_64 rnd64(rd());

template<typename T>
bool assign_max(T& a, T b) {
	if (b > a) {
		a = b;
		return true;
	}
	return false;
}

template<typename T>
bool assign_min(T& a, T b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}

template<typename T>
T square(T a) {
	return a * a;
}

template<>
struct std::hash<pair<ll, ll>> {
	ll operator() (pair<ll, ll> p) const {
		return ((__int128)p.first * MOD + p.second) % INF64;
	}
};

void solve() {
	ll n, b;
	cin >> n >> b;
	vector<ll> last(1 << b, n);
	vector<ll> arr(n);
	for (ll i = 0; i < n; i++) {
		cin >> arr[i];
	}
	vector<ll> ans(n, 0);
	ll mx = (1 << b) - 1;
	for (ll i = n - 1; i >= 0; i--) {
		if (arr[i] != 0) {
			for (ll j = arr[i]; j < (1 << b); j = (j + 1) | j) {
				last[j] = i;
			}
		}
		for (ll j = 0; j < b; j++) {
			ll now = mx ^ (1 << j);
			while (last[now] != n) {
				ans[i] += last[now] + 1;
				now = now & (mx ^ arr[last[now]]);
			}
		}
	}
	for (auto i : ans) {
		cout << i << ' ';
	}
	cout << '\n';
}

int main() {
	if (IS_FILE) {
		freopen("", "r", stdin);
		freopen("", "w", stdout);
	}
    	ios_base::sync_with_stdio(false);
    	cin.tie(0);
    	cout.tie(0);
	ll t = 1;
	if (IS_TEST_CASES) {
		cin >> t;
	}
	for (ll i = 0; i < t; i++) {
		solve();
	}
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 11268kb

input:

2000 20
251931 620255 725521 330111 783060 690627 489092 1019106 84341 631993 231500 920886 604265 342966 152434 588032 469990 805072 809795 12697 699326 433747 754394 567737 603087 199524 539078 775214 872735 454953 106496 93877 933762 36223 211878 168057 53977 782675 171782 455544 869778 47128 955...

output:

4467 4470 4471 4473 4476 4477 4481 4483 4657 4659 4662 4665 4686 5371 5372 5374 4697 4700 4701 4711 4713 4715 4719 4720 4721 4723 4727 4728 4738 4750 4851 4752 4754 4764 4765 4766 4767 4769 4775 4776 4778 4783 4790 4829 4830 4833 4834 4837 4842 4847 4848 4858 4864 4875 4876 4877 4878 4881 4890 5009 ...

result:

wrong answer 1st lines differ - expected: '10212 4259 4815 9101 17193 176...6 39925 39961 39974 43987 18000', found: '4467 4470 4471 4473 4476 4477 ... 5988 5991 5994 3997 3999 2000 '

Subtask #2:

score: 0
Wrong Answer

Test #4:

score: 0
Wrong Answer
time: 16ms
memory: 12932kb

input:

100000 20
262144 16 65536 8 256 1024 32 262144 16 262144 256 1024 1 64 2 131072 4096 2048 2 32 8192 4 2 262144 32768 1 524288 262144 262144 2048 8 64 1 2 8192 131072 256 64 8192 1 262144 4 32 4 524288 1 32768 16 64 128 8192 16 32 4096 16384 16384 4 131072 32768 16384 131072 2 16 2048 32768 16 4 4096...

output:

32 31 53 35 37 39 41 53 45 59 49 51 53 55 57 117 61 63 65 67 69 71 73 101 77 79 115 133 134 105 107 109 111 113 115 232 119 121 123 125 170 129 131 133 137 174 176 178 180 182 184 186 188 190 192 194 196 831 200 202 455 206 208 210 212 214 216 218 487 222 224 448 228 507 232 234 236 238 240 242 244 ...

result:

wrong answer 1st lines differ - expected: '7752 7885 8018 9329 9842 9956 ...7599886 5699943 3799981 1900000', found: '32 31 53 35 37 39 41 53 45 59 ...99996 99997 99998 99999 100000 '

Subtask #3:

score: 0
Wrong Answer

Test #6:

score: 0
Wrong Answer
time: 13ms
memory: 4604kb

input:

100000 8
98 78 5 190 79 234 162 79 118 176 115 130 10 9 233 56 97 15 148 13 46 87 92 65 150 62 50 46 159 101 48 86 203 71 29 124 23 228 55 161 240 80 139 74 251 143 167 207 183 52 50 252 17 185 40 145 167 164 227 166 172 60 182 62 173 227 232 243 251 134 109 241 44 33 217 149 51 6 110 201 242 196 23...

output:

2221 2743 2472 3581 3094 3097 2303 3165 3149 3225 2920 3542 3660 3537 3057 3743 3986 5581 3747 3635 4101 3590 3728 3563 3771 3554 4019 3891 3750 3746 3455 3904 3423 3385 3765 3933 4056 3526 2894 3322 3031 2811 2730 2879 3186 3210 3274 3115 2922 2907 2728 2113 2321 2919 3099 3158 3162 3806 3690 3697 ...

result:

wrong answer 1st lines differ - expected: '152631657 152630131 152630001 ...4 1199980 1199981 699995 500000', found: '2221 2743 2472 3581 3094 3097 ...90 399992 299995 199999 100000 '

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Skipped

Dependency #4:

0%

Subtask #6:

score: 0
Skipped

Dependency #1:

0%