QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#788483 | #9541. Expanding Array | ntxyl# | WA | 0ms | 3816kb | C++23 | 1.6kb | 2024-11-27 17:08:30 | 2024-11-27 17:08:32 |
Judging History
answer
#include <bits/stdc++.h>
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl '\n'
#define int long long
#define all(v) v.begin(), v.end()
//#define x first
//#define y second
using namespace std;
typedef pair<int, int> PII;
const int N = 1e5 + 10;
int qmi(int a,int b){
int res=1;
while(b){
if(b&1) res=res*a;
b>>=1;
a=a*a;
}
return res;
}
void solve() {
int n;
cin>>n;
vector<int>a(n+1);
// cout<<(1&1)<<endl;
for(int i=1;i<=n;i++) cin>>a[i];
set<int>s;
for(int i=1;i<n;i++){
int x=a[i],y=a[i+1],z=x^y;
int cnt1=0,cnt2=0,cnt3=0;
for(int j=0;j<=31;j++){
int xx=(x>>j)&1,yy=(y>>j)&1;
if(xx^yy) cnt1+=qmi(2,j);
if(xx|yy) cnt2+=qmi(2,j);
if(xx&yy) cnt3+=qmi(2,j);
}
s.insert({cnt1,cnt2,cnt3});
cnt1=0,cnt2=0,cnt3=0;
for(int j=0;j<=31;j++){
int xx=(x>>j)&1,yy=(z>>j)&1;
if(xx^yy) cnt1+=qmi(2,j);
if(xx|yy) cnt2+=qmi(2,j);
if(xx&yy) cnt3+=qmi(2,j);
}
s.insert({cnt1,cnt2,cnt3});
cnt1=0,cnt2=0,cnt3=0;
for(int j=0;j<=31;j++){
int xx=(y>>j)&1,yy=(z>>j)&1;
if(xx^yy) cnt1+=qmi(2,j);
if(xx|yy) cnt2+=qmi(2,j);
if(xx&yy) cnt3+=qmi(2,j);
}
s.insert({cnt1,cnt2,cnt3});
}
cout<<s.size()<<endl;
}
signed main() {
fastio;
int T;
T = 1;
// cin>>T;
while (T--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3816kb
input:
2 2 3
output:
4
result:
ok single line: '4'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3480kb
input:
2 3 4
output:
4
result:
ok single line: '4'
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3592kb
input:
2 3 5
output:
7
result:
wrong answer 1st lines differ - expected: '8', found: '7'