QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#775156#9541. Expanding ArrayKogenta2010WA 1ms3732kbC++141.0kb2024-11-23 14:55:082024-11-23 14:55:08

Judging History

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

  • [2024-11-23 14:55:08]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3732kb
  • [2024-11-23 14:55:08]
  • 提交

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(s.find(k1)==s.end()){
			//ans++;
			s.insert(k1);
			//cout<<"AND inserting "<<k<<endl;
			q.push((dat){now.prev,k1});
			q.push((dat){k1,now.next});
		}
		else if(s.find(k2)==s.end()){
			//ans++;00
			s.insert(k2);
			//cout<<"OR inserting "<<k<<endl;
			q.push((dat){now.prev,k2});
			q.push((dat){k2,now.next});
		}
		else if(s.find(k3)==s.end()){
			//ans++;
			s.insert(k3);
			//cout<<"XOR inserting "<<k<<endl;
			q.push((dat){now.prev,k3});
			q.push((dat){k3,now.next});
		}
	}
	cout<<s.size()<<endl;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
2 3

output:

4

result:

ok single line: '4'

Test #2:

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

input:

2
3 4

output:

3

result:

wrong answer 1st lines differ - expected: '4', found: '3'