Submission #605903

# Submission time Handle Problem Language Result Execution time Memory
605903 2022-07-26T04:20:07 Z kawaii Secret (JOI14_secret) C++14
0 / 100
468 ms 9320 KB
#include "secret.h"
#include<bits/stdc++.h>
using namespace std;
 
int a[1005], pre[1005][1005];
map<pair<int, int>, int> mp;

void Init(int N, int A[]){
    for(int i = 1; i <= N; i++) a[i] = A[i - 1];
    for(int i = 1; i <= N; i++) pre[i][i] = a[i];
    for(int i = 1; i <= 9; i++){
        for(int j = 1; j + (1 << i) - 1 <= N; j++){
            int val = Secret(pre[j][j + (1 << i - 1) - 1], pre[j + (1 << i - 1)][j + (1 << i) - 1]);
            pre[j][j + (1 << i) - 1] = val;
            mp[{pre[j][j + (1 << i - 1) - 1], pre[j + (1 << i - 1)][j + (1 << i) - 1]}] = mp[{pre[j + (1 << i - 1)][j + (1 << i) - 1], pre[j][j + (1 << i - 1) - 1]}] = val;
        }
    }
}
 
int Query(int L, int R){
    int ans = -1; L++; R++;
    int diff = R - L + 1;
    // cout << diff <<" ";
    for(int i = 0; i <= 9; i++){
        if((1 << i) & diff){
            if(ans == -1) ans = pre[L][L + (1 << i) - 1];
            else{
                if(mp[{ans, pre[L][L + (1 << i) - 1]}] == 0){
                    int val = Secret(ans, pre[L][L + (1 << i) - 1]);
                    mp[{ans, pre[L][L + (1 << i) - 1]}] = mp[{pre[L][L + (1 << i) - 1], ans}] = val;
                    ans = val;
                }
            }
            L += (1 << i);
        }
    }
    return ans;
}

Compilation message

secret.cpp: In function 'void Init(int, int*)':
secret.cpp:13:49: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   13 |             int val = Secret(pre[j][j + (1 << i - 1) - 1], pre[j + (1 << i - 1)][j + (1 << i) - 1]);
      |                                               ~~^~~
secret.cpp:13:76: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   13 |             int val = Secret(pre[j][j + (1 << i - 1) - 1], pre[j + (1 << i - 1)][j + (1 << i) - 1]);
      |                                                                          ~~^~~
secret.cpp:15:36: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   15 |             mp[{pre[j][j + (1 << i - 1) - 1], pre[j + (1 << i - 1)][j + (1 << i) - 1]}] = mp[{pre[j + (1 << i - 1)][j + (1 << i) - 1], pre[j][j + (1 << i - 1) - 1]}] = val;
      |                                  ~~^~~
secret.cpp:15:63: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   15 |             mp[{pre[j][j + (1 << i - 1) - 1], pre[j + (1 << i - 1)][j + (1 << i) - 1]}] = mp[{pre[j + (1 << i - 1)][j + (1 << i) - 1], pre[j][j + (1 << i - 1) - 1]}] = val;
      |                                                             ~~^~~
secret.cpp:15:111: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   15 |             mp[{pre[j][j + (1 << i - 1) - 1], pre[j + (1 << i - 1)][j + (1 << i) - 1]}] = mp[{pre[j + (1 << i - 1)][j + (1 << i) - 1], pre[j][j + (1 << i - 1) - 1]}] = val;
      |                                                                                                             ~~^~~
secret.cpp:15:155: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   15 |             mp[{pre[j][j + (1 << i - 1) - 1], pre[j + (1 << i - 1)][j + (1 << i) - 1]}] = mp[{pre[j + (1 << i - 1)][j + (1 << i) - 1], pre[j][j + (1 << i - 1) - 1]}] = val;
      |                                                                                                                                                         ~~^~~
# Verdict Execution time Memory Grader output
1 Incorrect 121 ms 4848 KB Wrong Answer: Query(24, 364) - expected : 538313475, actual : 592522065.
2 Incorrect 117 ms 4848 KB Wrong Answer: Query(127, 409) - expected : 507643944, actual : 889956480.
3 Incorrect 115 ms 4772 KB Wrong Answer: Query(286, 376) - expected : 755464542, actual : 615663878.
4 Incorrect 468 ms 9268 KB Wrong Answer: Query(548, 909) - expected : 117457562, actual : 813318716.
5 Incorrect 439 ms 9184 KB Wrong Answer: Query(12, 242) - expected : 776522766, actual : 941655040.
6 Incorrect 436 ms 9160 KB Wrong Answer: Query(319, 321) - expected : 727935331, actual : 256206461.
7 Incorrect 449 ms 9320 KB Wrong Answer: Query(16, 922) - expected : 799683707, actual : 52037739.
8 Incorrect 429 ms 9148 KB Wrong Answer: Query(23, 956) - expected : 880892032, actual : 140680.
9 Incorrect 462 ms 9168 KB Wrong Answer: Query(24, 950) - expected : 671229290, actual : 809511918.
10 Incorrect 463 ms 9200 KB Wrong Answer: Query(35, 904) - expected : 270608459, actual : 605520960.