Submission #675972

# Submission time Handle Problem Language Result Execution time Memory
675972 2022-12-28T17:01:35 Z abcvuitunggio Intergalactic ship (IZhO19_xorsum) C++17
100 / 100
1319 ms 27724 KB
#include <iostream>
#include <cstring>
#define int long long
using namespace std;
const int mod=1000000007;
int n,q,a[1001],dp[1010][1010][3],l[100001],r[100001],x[100001],pw=1,res;
void update(int i, int j, int i2, int j2, int idx){
    if (j>j2||i>i2)
        return;
    dp[i][j][idx]++;
    dp[i2+1][j][idx]--;
    dp[i][j2+1][idx]--;
    dp[i2+1][j2+1][idx]++;
}
int ch(int x, int y){
    return (!x?!y:(mod+1)/2);
}
int32_t main(){
    ios_base::sync_with_stdio(NULL);cin.tie(nullptr);
    cin >> n;
    for (int i=1;i<=n;i++)
        cin >> a[i];
    cin >> q;
    for (int i=1;i<=q;i++){
        cin >> l[i] >> r[i] >> x[i];
        pw=pw*2%mod;
    }
    for (int i=0;i<7;i++){
        for (int j=0;j<7;j++){
            memset(dp,0,sizeof(dp));
            for (int k=1;k<=q;k++)
                if ((x[k]>>i&1)&(x[k]>>j&1)){
                    update(l[k],l[k],r[k],r[k],0);
                    update(l[k],r[k]+1,r[k],n,1);
                    update(1,l[k],l[k]-1,r[k],2);
                }
                else if (x[k]>>i&1)
                    update(l[k],1,r[k],n,1);
                else if (x[k]>>j&1)
                    update(1,l[k],n,r[k],2);
            for (int x=1;x<=n;x++)
                for (int y=1;y<=n;y++)
                    for (int k=0;k<3;k++)
                        dp[x][y][k]+=dp[x][y-1][k]+dp[x-1][y][k]-dp[x-1][y-1][k];
            for (int x=1;x<=n;x++)
                for (int y=x;y<=n;y++){
                    int val=(1<<(i+j))*min(x,y)*(n-max(x,y)+1)%mod;
                    if (x<y)
                        val=val*2%mod;
                    int b=(a[x]>>i&1),c=(a[y]>>j&1);
                    for (int t=0;t<2;t++)
                        for (int t2=0;t2<2;t2++)
                            for (int t3=0;t3<2;t3++)
                                if ((b^t^t2)&(c^t^t3))
                                    res=(res+val*pw%mod*ch(dp[x][y][0],t)%mod*ch(dp[x][y][1],t2)%mod*ch(dp[x][y][2],t3)%mod)%mod;
                }
        }
    }
    cout << res;
}
# Verdict Execution time Memory Grader output
1 Correct 128 ms 24396 KB Output is correct
2 Correct 138 ms 24276 KB Output is correct
3 Correct 127 ms 24276 KB Output is correct
4 Correct 129 ms 24276 KB Output is correct
5 Correct 129 ms 24276 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 128 ms 24396 KB Output is correct
2 Correct 138 ms 24276 KB Output is correct
3 Correct 127 ms 24276 KB Output is correct
4 Correct 129 ms 24276 KB Output is correct
5 Correct 129 ms 24276 KB Output is correct
6 Correct 134 ms 24276 KB Output is correct
7 Correct 137 ms 24276 KB Output is correct
8 Correct 139 ms 24252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 199 ms 26612 KB Output is correct
2 Correct 143 ms 24588 KB Output is correct
3 Correct 139 ms 24276 KB Output is correct
4 Correct 137 ms 24276 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1183 ms 24288 KB Output is correct
2 Correct 1170 ms 24296 KB Output is correct
3 Correct 1125 ms 24372 KB Output is correct
4 Correct 1150 ms 24276 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 123 ms 24268 KB Output is correct
2 Correct 125 ms 24280 KB Output is correct
3 Correct 134 ms 24276 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 123 ms 24268 KB Output is correct
2 Correct 125 ms 24280 KB Output is correct
3 Correct 134 ms 24276 KB Output is correct
4 Correct 127 ms 24448 KB Output is correct
5 Correct 135 ms 24436 KB Output is correct
6 Correct 130 ms 24404 KB Output is correct
7 Correct 138 ms 24432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 128 ms 24396 KB Output is correct
2 Correct 138 ms 24276 KB Output is correct
3 Correct 127 ms 24276 KB Output is correct
4 Correct 129 ms 24276 KB Output is correct
5 Correct 129 ms 24276 KB Output is correct
6 Correct 134 ms 24276 KB Output is correct
7 Correct 137 ms 24276 KB Output is correct
8 Correct 139 ms 24252 KB Output is correct
9 Correct 123 ms 24268 KB Output is correct
10 Correct 125 ms 24280 KB Output is correct
11 Correct 134 ms 24276 KB Output is correct
12 Correct 148 ms 24284 KB Output is correct
13 Correct 147 ms 24296 KB Output is correct
14 Correct 140 ms 24276 KB Output is correct
15 Correct 137 ms 24276 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 128 ms 24396 KB Output is correct
2 Correct 138 ms 24276 KB Output is correct
3 Correct 127 ms 24276 KB Output is correct
4 Correct 129 ms 24276 KB Output is correct
5 Correct 129 ms 24276 KB Output is correct
6 Correct 134 ms 24276 KB Output is correct
7 Correct 137 ms 24276 KB Output is correct
8 Correct 139 ms 24252 KB Output is correct
9 Correct 123 ms 24268 KB Output is correct
10 Correct 125 ms 24280 KB Output is correct
11 Correct 134 ms 24276 KB Output is correct
12 Correct 127 ms 24448 KB Output is correct
13 Correct 135 ms 24436 KB Output is correct
14 Correct 130 ms 24404 KB Output is correct
15 Correct 138 ms 24432 KB Output is correct
16 Correct 148 ms 24284 KB Output is correct
17 Correct 147 ms 24296 KB Output is correct
18 Correct 140 ms 24276 KB Output is correct
19 Correct 137 ms 24276 KB Output is correct
20 Correct 538 ms 27664 KB Output is correct
21 Correct 553 ms 27688 KB Output is correct
22 Correct 422 ms 27584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 128 ms 24396 KB Output is correct
2 Correct 138 ms 24276 KB Output is correct
3 Correct 127 ms 24276 KB Output is correct
4 Correct 129 ms 24276 KB Output is correct
5 Correct 129 ms 24276 KB Output is correct
6 Correct 134 ms 24276 KB Output is correct
7 Correct 137 ms 24276 KB Output is correct
8 Correct 139 ms 24252 KB Output is correct
9 Correct 199 ms 26612 KB Output is correct
10 Correct 143 ms 24588 KB Output is correct
11 Correct 139 ms 24276 KB Output is correct
12 Correct 137 ms 24276 KB Output is correct
13 Correct 1183 ms 24288 KB Output is correct
14 Correct 1170 ms 24296 KB Output is correct
15 Correct 1125 ms 24372 KB Output is correct
16 Correct 1150 ms 24276 KB Output is correct
17 Correct 123 ms 24268 KB Output is correct
18 Correct 125 ms 24280 KB Output is correct
19 Correct 134 ms 24276 KB Output is correct
20 Correct 127 ms 24448 KB Output is correct
21 Correct 135 ms 24436 KB Output is correct
22 Correct 130 ms 24404 KB Output is correct
23 Correct 138 ms 24432 KB Output is correct
24 Correct 148 ms 24284 KB Output is correct
25 Correct 147 ms 24296 KB Output is correct
26 Correct 140 ms 24276 KB Output is correct
27 Correct 137 ms 24276 KB Output is correct
28 Correct 538 ms 27664 KB Output is correct
29 Correct 553 ms 27688 KB Output is correct
30 Correct 422 ms 27584 KB Output is correct
31 Correct 1319 ms 27688 KB Output is correct
32 Correct 1233 ms 27724 KB Output is correct
33 Correct 1243 ms 27596 KB Output is correct
34 Correct 1270 ms 27532 KB Output is correct
35 Correct 1222 ms 27492 KB Output is correct
36 Correct 1184 ms 27532 KB Output is correct