QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#775214#9541. Expanding ArrayKogenta2010WA 850ms34924kbC++141.1kb2024-11-23 15:03:352024-11-23 15:03:36

Judging History

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

  • [2024-11-23 15:03:36]
  • 评测
  • 测评结果:WA
  • 用时:850ms
  • 内存:34924kb
  • [2024-11-23 15:03:35]
  • 提交

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(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(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(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: 3520kb

input:

2
2 3

output:

4

result:

ok single line: '4'

Test #2:

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

input:

2
3 4

output:

4

result:

ok single line: '4'

Test #3:

score: 0
Accepted
time: 1ms
memory: 3496kb

input:

2
3 5

output:

8

result:

ok single line: '8'

Test #4:

score: 0
Accepted
time: 1ms
memory: 3740kb

input:

10
37760128 12721860 37519778 33518004 2760086 4473592 65451644 83416788 44877547 36766460

output:

56

result:

ok single line: '56'

Test #5:

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

input:

10
816913051 502168112 623785107 464692422 886370488 155984202 681252443 57479616 856353914 365166224

output:

56

result:

ok single line: '56'

Test #6:

score: 0
Accepted
time: 741ms
memory: 32380kb

input:

91141
991550420 630736630 613860632 683288307 801076961 655640638 825594849 292357587 386886324 280046446 969805344 558863217 285710238 677412106 663841817 331062932 665933557 860995134 10312018 472942826 92468113 114082647 184016662 952783745 869957199 427809351 730297077 324218702 340532370 865197...

output:

546842

result:

ok single line: '546842'

Test #7:

score: 0
Accepted
time: 850ms
memory: 34924kb

input:

99990
436733915 194729865 822464090 159380426 605947779 183500385 914253010 997171386 178142524 922229524 628470895 249318241 529701470 622239344 652486908 19042637 861164615 977371879 683176583 935482867 570862807 829803280 731891684 893345580 932602100 619651621 736491818 784943027 460885255 59290...

output:

599936

result:

ok single line: '599936'

Test #8:

score: -100
Wrong Answer
time: 821ms
memory: 33472kb

input:

100000
487226969 457282779 405894670 507533594 752274125 691586010 899032024 977434663 549675232 670910087 246449945 121814497 42291126 10848596 700944136 358865545 712590631 568312324 399031386 687281452 313519716 238165298 674312548 467926333 766512188 954885325 666026653 533479054 583530932 45267...

output:

576806

result:

wrong answer 1st lines differ - expected: '579323', found: '576806'