QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#775228 | #9541. Expanding Array | Kogenta2010 | WA | 1ms | 3736kb | C++14 | 1.1kb | 2024-11-23 15:05:48 | 2024-11-23 15:05:48 |
Judging History
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'