# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
371194 | 2021-02-26T04:38:23 Z | daniel920712 | Intergalactic ship (IZhO19_xorsum) | C++14 | 2000 ms | 12672 KB |
#include <iostream> #include <stdio.h> #include <stdlib.h> #include <vector> 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]; vector < long long > how[200005]; long long con[105][35]={0}; long long ttt[100005][35]={0}; long long Pow[200005]={0}; long long xx[200005]={0}; 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,k,l,x=1,y=1,z=1,ok=1,ans2=0; 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; } Pow[0]=1; for(i=0;i<M;i++) { Pow[i+1]=Pow[i]*2%MOD; z*=2; z%=MOD; } for(i=0;i<M;i++) { scanf("%lld %lld %lld",&tt[i].first.first,&tt[i].first.second,&tt[i].second); if(tt[i].first.second-tt[i].first.first) ok=0; how[tt[i].first.first].push_back(tt[i].second); xx[tt[i].first.first]++; } /*if(M<=20) F(0); else if(ok==0) { 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; } } } } else*/ { F(0); for(i=1;i<=N;i++) { for(j=0;j<32;j++) ttt[0][j]=0; ttt[0][all[i]]=1; for(j=0;j<xx[i];j++) { for(k=0;k<32;k++) ttt[j+1][k]=ttt[j][k]; for(k=0;k<32;k++) { ttt[j+1][k^how[i][j]]+=ttt[j][k]; ttt[j+1][k^how[i][j]]%=MOD; } } for(j=0;j<32;j++) { con[i][j]=ttt[xx[i]][j]; //if(con[i][j]) printf("%lld %lld %lld\n",i,j,con[i][j]); } } ans2=0; for(i=1;i<=N;i++) { for(j=0;j<32;j++) { ans2+=j*j%MOD*con[i][j]%MOD*Pow[M-xx[i]]%MOD*i%MOD*(N-i+1)%MOD; ans2%=MOD; } for(j=i+1;j<=N;j++) { //printf("aa %lld\n",Pow[M-xx[i]-xx[j]]); for(k=0;k<32;k++) { for(l=0;l<32;l++) { ans2+=2*k*l*con[i][k]%MOD*con[j][l]%MOD*Pow[M-xx[i]-xx[j]]%MOD*i%MOD*(N-j+1)%MOD; ans2%=MOD; } } } } //printf("%lld %lld\n",ans,ans2); ans=ans2; } printf("%lld\n",ans); return 0; } //936
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 5100 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 5100 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2085 ms | 12672 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2085 ms | 5100 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1188 ms | 5124 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1188 ms | 5124 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 5100 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 5100 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 5100 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |