QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#775228#9541. Expanding ArrayKogenta2010WA 1ms3736kbC++141.1kb2024-11-23 15:05:482024-11-23 15:05:48

Judging History

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

  • [2024-11-23 15:05:48]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3736kb
  • [2024-11-23 15:05:48]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
set<int>s;
struct dat{
	int prev;
	int next;
};
queue<dat>q;
int main(){
	int n,x,y;
	cin>>n;
	//int ans=0;
	for(int i=1;i<=n;i++){
		cin>>x;
		if(s.find(x)==s.end()){
			s.insert(x);
			//ans++;
		}
		if(i>1){
			q.push((dat){y,x});
		}
		y=x;
	}
	dat now;
	int k1,k2,k3;
	while(!q.empty()){
		now=q.front();
		q.pop();
		//cout<<now.next<<" "<<now.prev<<endl;
		k1=now.prev&now.next;
		k2=now.prev|now.next;
		k3=now.prev^now.next;
		if(k2!=0&&s.find(k2)==s.end()){
			//ans++;00
			s.insert(k2);
			//cout<<"OR inserting "<<k2<<endl;
			q.push((dat){now.prev,k2});
			q.push((dat){k2,now.next});
		}
		else if(k3!=0&&s.find(k3)==s.end()){
			//ans++;
			s.insert(k3);
			//cout<<"XOR inserting "<<k3<<endl;
			q.push((dat){now.prev,k3});
			q.push((dat){k3,now.next});
		}
		else if(k1!=0&&s.find(k1)==s.end()){
			//ans++;
			s.insert(k1);
			//cout<<"AND inserting "<<k1<<endl;
			q.push((dat){now.prev,k1});
			q.push((dat){k1,now.next});
		}
	}
	if(s.find(0)==s.end()){
		s.insert(0);
	}
	cout<<s.size()<<endl;
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3736kb

input:

2
2 3

output:

4

result:

ok single line: '4'

Test #2:

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

input:

2
3 4

output:

4

result:

ok single line: '4'

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 3520kb

input:

2
3 5

output:

6

result:

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