QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#775156 | #9541. Expanding Array | Kogenta2010 | WA | 1ms | 3732kb | C++14 | 1.0kb | 2024-11-23 14:55:08 | 2024-11-23 14:55:08 |
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(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'