QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#556560#4810. Add Onestack343WA 0ms4024kbC++232.1kb2024-09-10 19:22:222024-09-10 19:22:23

Judging History

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

  • [2024-09-10 19:22:23]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:4024kb
  • [2024-09-10 19:22:22]
  • 提交

answer

#pragma GCC optimize("Ofast")
 
#include <bits/stdc++.h>   
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;   
using namespace std;
#define ll long long
#define ld long double
#define nline "\n"
#define f first
#define s second
#define sz(x) (ll)x.size()
#define vl vector<ll>
const ll INF_MUL=1e13;
const ll INF_ADD=1e18;
#define all(x) x.begin(),x.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------     
const ll MOD=998244353;
const ll MAX=500500;
struct get_xor{
    array<ll,61> basis;
    get_xor(){
        for(ll bit=0;bit<=60;bit++){
            basis[bit]=0; 
        }
    }
    void insert_mask(ll mask){
        for(ll bit=0;bit<=60;bit++){
            if(mask&(1ll<<bit)){
                if(!basis[bit]){
                    basis[bit]=mask;
                    return; 
                }
                mask^=basis[bit]; 
            }
        }
    }
};
void solve(){ 
  ll n,total=0; cin>>n;
  get_xor track;
  for(ll i=1;i<=n;i++){
    ll x; cin>>x;
    track.insert_mask(x);
    total^=x;
  }
  ll ans=total+1,cur=0;
  for(ll i=0;i<=60;i++){
    ll l=cur,r=total^cur;
    l++;
    ans=max(ans,l+r);
    if(cur&(1ll<<i)){
      ;
    }
    else{
      cur^=track.basis[i];
    }
  }
  cout<<ans<<nline;
  return;    
}  
int main()                                                                                 
{         
  ios_base::sync_with_stdio(false);                         
  cin.tie(NULL);                              
  ll test_cases=1;                 
  //cin>>test_cases;
  while(test_cases--){
    solve();
  }
  cout<<fixed<<setprecision(12);  
  cerr<<"Time:"<<1000*((double)clock())/(double)CLOCKS_PER_SEC<<"ms\n"; 
} 

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 4024kb

input:

4
1 2 1 2

output:

7

result:

ok 1 number(s): "7"

Test #2:

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

input:

5
1 2 3 4 5

output:

14

result:

ok 1 number(s): "14"

Test #3:

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

input:

6
1 2 4 7 15 31

output:

47

result:

ok 1 number(s): "47"

Test #4:

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

input:

5
41 40 50 11 36

output:

99

result:

ok 1 number(s): "99"

Test #5:

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

input:

6
10 40 60 2 44 47

output:

96

result:

ok 1 number(s): "96"

Test #6:

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

input:

6
46 25 39 47 23 60

output:

107

result:

ok 1 number(s): "107"

Test #7:

score: -100
Wrong Answer
time: 0ms
memory: 3784kb

input:

6
56 90 61 63 56 23

output:

176

result:

wrong answer 1st numbers differ - expected: '112', found: '176'