Submission #540768

#TimeUsernameProblemLanguageResultExecution timeMemory
540768WaelSecret (JOI14_secret)C++14
0 / 100
20073 ms4348 KiB
#include "secret.h" #include<bits/stdc++.h> using namespace std; typedef long long ll; #define F first #define S second #define endl '\n' int const M = (1 << 10); set<pair<pair<ll , ll> , ll>>st; ll val , size = 1 , l , r , t , x , y , n , m , s[M]; vector<ll>sum , op; vector<ll>elem[3][M]; inline ll Ask(int x , int y) { return Secret(x , y); } inline void Build(int x , int lx , int rx) { int mid = (rx - lx + 1) / 2; elem[1][x].push_back(s[mid]); for(int i = mid - 1 ; i >= lx ; --i) { ll res = Ask(s[i] , elem[1][x].back()); elem[1][x].push_back(res); } reverse(elem[1][x].begin() , elem[1][x].end()); elem[2][x].push_back(s[mid + 1]); for(int i = mid + 2 ; i <= rx ; ++i) { ll res = Ask(s[i] , elem[2][x].back()); } } inline ll Get(int l , int r , int x , int lx , int rx) { int mid = (lx + rx) / 2; if(mid >= l && mid <= r) { ll val1 = elem[1][x][mid - l]; ll val2 = elem[2][x][r - mid]; return Ask(val1 , val2); } else if(mid + 1 >= l && mid + 1 <= r) { ll val1 = elem[1][x][(mid + 1) - l]; ll val2 = elem[2][x][r - (mid + 1)]; return Ask(val1 , val2); } if(mid + 1 < l) return Get(l , r , 2 * x , lx , mid); else return Get(l , r , 2 * x + 1 , mid + 1 , rx); } void Init(int N, int A[]) { for(int i = 1 ; i <= N ; ++i) s[i] = A[i]; Build(1 , 1 , M); } int Query(int L, int R) { cout << Get(L , R , 1 , 1 , size) << endl; return 0; }

Compilation message (stderr)

secret.cpp: In function 'void Build(int, int, int)':
secret.cpp:31:12: warning: unused variable 'res' [-Wunused-variable]
   31 |         ll res = Ask(s[i] , elem[2][x].back());
      |            ^~~
secret.cpp: In function 'void Init(int, int*)':
secret.cpp:31:25: warning: iteration 510 invokes undefined behavior [-Waggressive-loop-optimizations]
   31 |         ll res = Ask(s[i] , elem[2][x].back());
      |                      ~~~^
secret.cpp:30:30: note: within this loop
   30 |      for(int i = mid + 2 ; i <= rx ; ++i) {
      |                            ~~^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...