QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#763947#9541. Expanding ArrayGazeWA 0ms3700kbC++14789b2024-11-19 22:57:272024-11-19 22:57:28

Judging History

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

  • [2024-11-19 22:57:28]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3700kb
  • [2024-11-19 22:57:27]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
inline int read() {
	int x = 0, f = 1;
	char ch = getchar();
	while(ch < '0' || ch > '9') {
		if(ch == '-') f = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		x = (x << 1) + (x << 3) + (ch ^ 48);
		ch = getchar();
	}
	return x * f;
} 
int n, ans;
int f[10010];
map<int, int> mp;
void count(int x, int y) {
	int a = x & y, b = x | y, c = x ^ y;
	if(mp[a] == 0) {
		mp[a] = 1;
		ans += 1;
	}
	if(mp[b] == 0) {
		mp[b] = 1;
		ans += 1;
	}
	if(mp[c] == 0) {
		mp[c] = 1;
		ans += 1;
	} 
}
int main() {
	n = read();
	ans = n + 1;
	mp[0] = 1;
	for(int i = 1; i <= n; ++i) {
		f[i] = read();
		mp[f[i]] = 1;
	}
	for(int i = 1; i < n; ++i) {
		count(f[i], f[i + 1]);
	}
	cout << ans << endl;
} 

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
2 3

output:

4

result:

ok single line: '4'

Test #2:

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

input:

2
3 4

output:

4

result:

ok single line: '4'

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3568kb

input:

2
3 5

output:

6

result:

wrong answer 1st lines differ - expected: '8', found: '6'