QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#724897 | #9541. Expanding Array | lxl# | TL | 0ms | 3808kb | C++20 | 630b | 2024-11-08 15:29:07 | 2024-11-08 15:29:07 |
Judging History
answer
#include<bits/stdc++.h>
using ll = long long;
std::set<std::pair<int, int>> setp;
std::set<int> set;
inline void dfs(int x, int y) {
if(x > y) std::swap(x, y);
if(setp.count({x, y})) return;
set.insert(x);
set.insert(y);
setp.insert({x, y});
dfs(x, x & y);
dfs(x, x | y);
dfs(x, x ^ y);
dfs(y, x & y);
dfs(y, x | y);
dfs(y, x ^ y);
}
void solve(){
int n; std::cin >> n;
std::vector<int> v(n);
for(int i = 0; i < n; i++) {
std::cin >> v[i];
}
for(int i = 1; i < n; i++) {
dfs(v[i - 1], v[i]);
}
std::cout << set.size() << '\n';
}
int main(){
int t = 1;
while(t--) solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3808kb
input:
2 2 3
output:
4
result:
ok single line: '4'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
2 3 4
output:
4
result:
ok single line: '4'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
2 3 5
output:
8
result:
ok single line: '8'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3484kb
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: 3548kb
input:
10 816913051 502168112 623785107 464692422 886370488 155984202 681252443 57479616 856353914 365166224
output:
56
result:
ok single line: '56'
Test #6:
score: -100
Time Limit Exceeded
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...