QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#113192 | #4446. Link is as bear | Liuf# | WA | 648ms | 22208kb | C++20 | 1.6kb | 2023-06-16 17:20:30 | 2023-06-16 17:20:30 |
Judging History
answer
#include<bits/stdc++.h>
#define endl '\n'
#define pii pair<int, int>
#define int long long
#define ld long double
using namespace std;
const int mod=1e9+7,M=2000010,Mlog=22;
void solve(){
int n;
cin>>n;
vector<int>a(n+1),b(n+1,0),v;
map<int,vector<int>>m;
set<int>s;
for(int i=1;i<=n;i++){
cin>>a[i];
m[a[i]].push_back(i);
s.insert(a[i]);
}
for(int x:s){
v.push_back(x);
}
reverse(v.begin(),v.end());
if(m.size()==1){
for(auto [x,_]:m){
cout<<x<<endl;
return;
}
}
for(int i=1;i<=n;i++){
b[i]=b[i-1]^a[i];
}
int ans=0;
for(auto x:v){
int ok=1;
for(int i=0;i<m[x].size();i++){
if(!i){
if(b[m[x][i]-1]!=x&&m[x][i]!=1){
ok=0;
break;
}
} else{
if(m[x][i]!=m[x][i-1]+1){
if(b[m[x][i]-1]^b[m[x][i-1]]!=x){
ok=0;
break;
}
}
}
}
if(m[x].back()!=n){
if(b[n]^b[m[x].back()]!=x){
ok=0;
}
}
if(ok){
ans=x;
break;
}
}
cout<<max(ans,b[n])<<endl;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin>>t;
while(t--){
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 648ms
memory: 22208kb
input:
22222 100000 595189703884863 72716684812661 449525802123580 504421888022388 390139608591346 108895143840760 170477720052912 185583843894744 201608404318832 128831549357316 521084715261656 668960191579878 573530403227342 489014525501629 56366633717911 1705111713690 227582321537214 710815946393065 169...
output:
367105242564297 80685774788852 905452073216932 800506481918522 913657452217541 299196809323710 667132970972809 121078747625910 167632099646865 737568965050208 22049392616706 711945311050738 1106277129968908 161653562054199 1108034298121334 707664136718665 712603298471237 681235366385653 929752393702...
result:
wrong answer 1st lines differ - expected: '1125899906842623', found: '367105242564297'