답안 #337463

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
337463 2020-12-20T22:16:10 Z scales Intergalactic ship (IZhO19_xorsum) C++17
9 / 100
2000 ms 2668 KB
#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;
long long M=1000000007;
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;
                    sum=sum%M;
                }
            }
           // cout<<"sum="<<sum<<endl;

        }
        cout<<sum<<endl;
    }

    return 0;
}

Compilation message

xorsum.cpp: In function 'int main()':
xorsum.cpp:17:15: warning: unused variable 't' [-Wunused-variable]
   17 |     long long t,i,j,mini,x,y,z,q,m,k,kol,x1,tip,g,maxi,n,y1,sum;
      |               ^
xorsum.cpp:17:21: warning: unused variable 'mini' [-Wunused-variable]
   17 |     long long t,i,j,mini,x,y,z,q,m,k,kol,x1,tip,g,maxi,n,y1,sum;
      |                     ^~~~
xorsum.cpp:17:28: warning: unused variable 'y' [-Wunused-variable]
   17 |     long long t,i,j,mini,x,y,z,q,m,k,kol,x1,tip,g,maxi,n,y1,sum;
      |                            ^
xorsum.cpp:17:36: warning: unused variable 'k' [-Wunused-variable]
   17 |     long long t,i,j,mini,x,y,z,q,m,k,kol,x1,tip,g,maxi,n,y1,sum;
      |                                    ^
xorsum.cpp:17:38: warning: unused variable 'kol' [-Wunused-variable]
   17 |     long long t,i,j,mini,x,y,z,q,m,k,kol,x1,tip,g,maxi,n,y1,sum;
      |                                      ^~~
xorsum.cpp:17:42: warning: unused variable 'x1' [-Wunused-variable]
   17 |     long long t,i,j,mini,x,y,z,q,m,k,kol,x1,tip,g,maxi,n,y1,sum;
      |                                          ^~
xorsum.cpp:17:45: warning: unused variable 'tip' [-Wunused-variable]
   17 |     long long t,i,j,mini,x,y,z,q,m,k,kol,x1,tip,g,maxi,n,y1,sum;
      |                                             ^~~
xorsum.cpp:17:49: warning: unused variable 'g' [-Wunused-variable]
   17 |     long long t,i,j,mini,x,y,z,q,m,k,kol,x1,tip,g,maxi,n,y1,sum;
      |                                                 ^
xorsum.cpp:17:51: warning: unused variable 'maxi' [-Wunused-variable]
   17 |     long long t,i,j,mini,x,y,z,q,m,k,kol,x1,tip,g,maxi,n,y1,sum;
      |                                                   ^~~~
xorsum.cpp:17:58: warning: unused variable 'y1' [-Wunused-variable]
   17 |     long long t,i,j,mini,x,y,z,q,m,k,kol,x1,tip,g,maxi,n,y1,sum;
      |                                                          ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 28 ms 364 KB Output is correct
7 Correct 28 ms 364 KB Output is correct
8 Correct 29 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 21 ms 2668 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2065 ms 364 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2065 ms 364 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 28 ms 364 KB Output is correct
7 Correct 28 ms 364 KB Output is correct
8 Correct 29 ms 364 KB Output is correct
9 Execution timed out 2065 ms 364 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 28 ms 364 KB Output is correct
7 Correct 28 ms 364 KB Output is correct
8 Correct 29 ms 364 KB Output is correct
9 Execution timed out 2065 ms 364 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 28 ms 364 KB Output is correct
7 Correct 28 ms 364 KB Output is correct
8 Correct 29 ms 364 KB Output is correct
9 Incorrect 21 ms 2668 KB Output isn't correct
10 Halted 0 ms 0 KB -