提出 #5277490


ソースコード 拡げる

#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL N;
	in >> N;
	std::vector<LL>A(N);
	rep(i, N) in >> A[i];

	std::vector<LL>cnt(31);
	LL sum = 0, XOR = 0;
	rep(i, N)
	{
		rep(j, 30)
		{
			if (A[i] & (1LL << j)) ++cnt[j];
		}
		sum += A[i];
		XOR ^= A[i];

		LL ans = 0;
		rep(j, 30)
		{
			if (XOR & (1LL << j)) ans += (1LL << j) * (i + 1 - cnt[j]);
			else ans += (1LL << j) * cnt[j];
		}
		out << ans << std::endl;
	}
}

提出情報

提出日時
問題 E - Enumerate Xor Sum
ユーザ babcs2035
言語 C++14 (GCC 5.4.1)
得点 500
コード長 555 Byte
結果 AC
実行時間 671 ms
メモリ 7040 KiB

ジャッジ結果

セット名 All sample
得点 / 配点 500 / 500 0 / 0
結果
AC × 22
AC × 2
セット名 テストケース
All 01_small_random, 02_small_random, 03_small_random, 04_small_random, 05_small_random, 06_small_random, 07_small_random, 08_small_random, 09_small_random, 10_small_random, 11_large_random, 12_large_random, 13_large_random, 14_large_random, 15_large_random, 16_large_random, 17_large_random, 18_large_random, 19_large_random, 20_large_random, sample_1, sample_2
sample sample_1, sample_2
ケース名 結果 実行時間 メモリ
01_small_random AC 1 ms 256 KiB
02_small_random AC 1 ms 256 KiB
03_small_random AC 1 ms 256 KiB
04_small_random AC 1 ms 256 KiB
05_small_random AC 1 ms 256 KiB
06_small_random AC 1 ms 256 KiB
07_small_random AC 1 ms 256 KiB
08_small_random AC 1 ms 256 KiB
09_small_random AC 1 ms 256 KiB
10_small_random AC 1 ms 256 KiB
11_large_random AC 659 ms 7040 KiB
12_large_random AC 660 ms 7040 KiB
13_large_random AC 663 ms 7040 KiB
14_large_random AC 671 ms 7040 KiB
15_large_random AC 664 ms 7040 KiB
16_large_random AC 668 ms 7040 KiB
17_large_random AC 659 ms 7040 KiB
18_large_random AC 669 ms 7040 KiB
19_large_random AC 661 ms 7040 KiB
20_large_random AC 662 ms 7040 KiB
sample_1 AC 1 ms 256 KiB
sample_2 AC 1 ms 256 KiB