Submission #605908

#TimeUsernameProblemLanguageResultExecution timeMemory
605908kawaiiSecret (JOI14_secret)C++14
0 / 100
472 ms8792 KiB
#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]}] = 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]}] = val; ans = val; } } L += (1 << i); } } return ans; }

Compilation message (stderr)

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]}] = 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]}] = val;
      |                                                             ~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...