# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
371164 | daniel920712 | Intergalactic ship (IZhO19_xorsum) | C++14 | 1182 ms | 3692 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
long long all[200005];
long long a[200005];
long long b[200005];
long long c[200005];
pair < pair < long long , long long > , long long > tt[200005];
long long ans=0,N,M,MOD=1e9+7;
void F(long long here)
{
long long i,j,t;
if(here==M)
{
t=0;
for(i=1;i<=N;i++)
{
t+=2*all[i]*(N-i+1)%MOD;
t%=MOD;
}
for(i=1;i<=N;i++)
{
ans+=all[i]*all[i]*i*(N-i+1);
ans%=MOD;
t-=2*all[i]*(N-i+1)%MOD;
t+=MOD;
t%=MOD;
ans+=all[i]*i*t%MOD;
ans%=MOD;
}
return;
}
F(here+1);
for(i=tt[here].first.first;i<=tt[here].first.second;i++) all[i]^=tt[here].second;
F(here+1);
for(i=tt[here].first.first;i<=tt[here].first.second;i++) all[i]^=tt[here].second;
}
int main()
{
long long i,j,x=1,y=1,z=1;
scanf("%lld",&N);
for(i=1;i<=N;i++)
{
scanf("%lld",&all[i]);
a[i]=all[i];
b[i]=-1;
c[i]=-1;
}
scanf("%lld",&M);
for(i=0;i<M-2;i++)
{
x*=2;
x%=MOD;
}
for(i=0;i<M-1;i++)
{
y*=2;
y%=MOD;
}
for(i=0;i<M;i++)
{
z*=2;
z%=MOD;
}
//printf("%lld\n",M);
for(i=0;i<M;i++) scanf("%lld %lld %lld",&tt[i].first.first,&tt[i].first.second,&tt[i].second);
if(M<=20)
{
F(0);
}
else
{
for(i=0;i<M;i++)
{
for(j=tt[i].first.first;j<=tt[i].first.second;j++)
{
b[j]=a[j]^tt[i].second;
c[j]=i;
}
}
for(i=1;i<=N;i++)
{
if(b[i]==-1)
{
ans+=z*a[i]*a[i]*i*(N-i+1)%MOD;
ans%=MOD;
}
else
{
ans+=y*a[i]*a[i]*i*(N-i+1)%MOD;
ans%=MOD;
ans+=y*b[i]*b[i]*i*(N-i+1)%MOD;
ans%=MOD;
}
for(j=i+1;j<=N;j++)
{
if(b[i]==-1&&b[j]==-1)
{
ans+=2*z*a[i]*a[j]*i*(N-j+1)%MOD;
ans%=MOD;
}
else if(b[i]==-1)
{
ans+=2*y*a[i]*a[j]*i*(N-j+1)%MOD;
ans%=MOD;
ans+=2*y*a[i]*b[j]*i*(N-j+1)%MOD;
ans%=MOD;
}
else if(b[j]==-1)
{
ans+=2*y*a[i]*a[j]*i*(N-j+1)%MOD;
ans%=MOD;
ans+=2*y*b[i]*a[j]*i*(N-j+1)%MOD;
ans%=MOD;
}
else if(c[i]==c[j])
{
ans+=2*y*a[i]*a[j]*i*(N-j+1)%MOD;
ans%=MOD;
ans+=2*y*b[i]*b[j]*i*(N-j+1)%MOD;
ans%=MOD;
}
else
{
ans+=2*x*a[i]*a[j]*i*(N-j+1)%MOD;
ans%=MOD;
ans+=2*x*b[i]*b[j]*i*(N-j+1)%MOD;
ans%=MOD;
ans+=2*x*a[i]*b[j]*i*(N-j+1)%MOD;
ans%=MOD;
ans+=2*x*b[i]*a[j]*i*(N-j+1)%MOD;
ans%=MOD;
}
}
}
}
printf("%lld\n",ans);
return 0;
}
컴파일 시 표준 에러 (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... |