# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
337460 | scales | Intergalactic ship (IZhO19_xorsum) | C++17 | 861 ms | 3564 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
/*#ifndef LOCAL_RUN
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("avx2,tune=native")
#endif*/
////////////////////BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
//freopen("","r",stdin);
//freopen("","w",stdout);
long long t,i,j,mini,x,y,z,q,m,k,kol,x1,tip,g,maxi,n,y1,sum;
cin>>n;
vector<long long> a(n),b(n);
for(i=0;i<n;i++)
{
cin>>a[i];
}
cin>>m;
vector<long long> l(m),r(m),v(m);
for(i=0;i<m;i++)
{
cin>>l[i];
cin>>r[i];
l[i]--;
r[i]--;
cin>>v[i];
}
vector<long long> pref(n);
if(m<=20)
{
vector<long long> st(21);
st[0]=1;
for(i=1;i<=20;i++)
{
st[i]=2*st[i-1];
}
//cout<<"aaaaaaa"<<endl;
sum=0;
for(i=0;i<st[m];i++)
{
//cout<<"i="<<i<<endl;
for(j=0;j<n;j++)
{
b[j]=a[j];
}
for(j=0;j<m;j++)
{
z=st[j]&i;
//cout<<"z="<<z<<endl;
if(z!=0)
{
for(q=l[j];q<=r[j];q++)
{
b[q]=b[q]^v[j];
//cout<<"a b[q]="<<b[q]<<endl;
}
}
}
pref[0]=b[0];
// cout<<"pref[0]="<<pref[0]<<endl;
for(j=1;j<n;j++)
{
pref[j]=pref[j-1]+b[j];
// cout<<"b[j]="<<b[j]<<" pref["<<j<<"]="<<pref[j]<<endl;
}
//cout<<"sum="<<sum<<endl;
for(j=0;j<n;j++)
{
for(q=j;q<n;q++)
{
x=pref[q];
if(j!=0)
{
x=x-pref[j-1];
}
x=x*x;
//cout<<"x="<<x<<" ";
sum=sum+x;
}
}
// cout<<"sum="<<sum<<endl;
}
cout<<sum<<endl;
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |