Submission #974842

# Submission time Handle Problem Language Result Execution time Memory
974842 2024-05-04T00:59:19 Z aaaaaarroz Secret (JOI14_secret) C++17
30 / 100
433 ms 4664 KB
#include <bits/stdc++.h>
using namespace std;
int Secret(int l, int r);
template<class T, T m_(T, T)> struct SegmentTree{
  int n; vector<T> ST;
  SegmentTree(){}
  SegmentTree(vector<T> &a){
    n = a.size(); ST.resize(n << 1);
    for (int i=n;i<(n<<1);i++)ST[i]=a[i-n];
    for (int i=n-1;i>0;i--)ST[i]=m_(ST[i<<1],ST[i<<1|1]);
  }
  void update(int pos, T val){ // replace with val
    ST[pos += n] = val;
    for (pos >>= 1; pos > 0; pos >>= 1)
      ST[pos] = m_(ST[pos<<1], ST[pos<<1|1]);
  }
  T query(int l, int r){ // [l, r]
    T ansL, ansR; bool hasL = 0, hasR = 0;
    for (l += n, r += n + 1; l < r; l >>= 1, r >>= 1) {
      if (l & 1) 
        ansL=(hasL?m_(ansL,ST[l++]):ST[l++]),hasL=1;
      if (r & 1) 
        ansR=(hasR?m_(ST[--r],ansR):ST[--r]),hasR=1;
    }
    if (!hasL) return ansR; if (!hasR) return ansL;
    return m_(ansL, ansR);
  }
}; // Give vector of leaves and merge function
 
int merge(int a,int b){
	return (Secret(a,b));
}
vector<int>AA;
SegmentTree<int,merge>st(AA);
void Init(int n, int a[]){
	vector<int>arr(n);
	for(int i=0;i<n;i++){
		arr[i]=a[i];
	}
	SegmentTree<int,merge>stt(arr);
	st=stt;
}
int Query(int l,int r){ 
	return st.query(l,r);
}

Compilation message

secret.cpp: In member function 'T SegmentTree<T, m_>::query(int, int)':
secret.cpp:25:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   25 |     if (!hasL) return ansR; if (!hasR) return ansL;
      |     ^~
secret.cpp:25:29: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   25 |     if (!hasL) return ansR; if (!hasR) return ansL;
      |                             ^~
secret.cpp: In function 'int Query(int, int)':
secret.cpp:44:21: warning: 'ansR' may be used uninitialized in this function [-Wmaybe-uninitialized]
   44 |  return st.query(l,r);
      |                     ^
# Verdict Execution time Memory Grader output
1 Partially correct 136 ms 2652 KB Output is partially correct - number of calls to Secret by Init = 510, maximum number of calls to Secret by Query = 14
2 Partially correct 138 ms 2652 KB Output is partially correct - number of calls to Secret by Init = 511, maximum number of calls to Secret by Query = 14
3 Partially correct 147 ms 2808 KB Output is partially correct - number of calls to Secret by Init = 512, maximum number of calls to Secret by Query = 13
4 Partially correct 433 ms 4348 KB Output is partially correct - number of calls to Secret by Init = 998, maximum number of calls to Secret by Query = 15
5 Partially correct 411 ms 4664 KB Output is partially correct - number of calls to Secret by Init = 999, maximum number of calls to Secret by Query = 14
6 Partially correct 371 ms 4336 KB Output is partially correct - number of calls to Secret by Init = 999, maximum number of calls to Secret by Query = 4
7 Partially correct 420 ms 4340 KB Output is partially correct - number of calls to Secret by Init = 999, maximum number of calls to Secret by Query = 16
8 Partially correct 422 ms 4340 KB Output is partially correct - number of calls to Secret by Init = 999, maximum number of calls to Secret by Query = 16
9 Partially correct 419 ms 4436 KB Output is partially correct - number of calls to Secret by Init = 999, maximum number of calls to Secret by Query = 15
10 Partially correct 417 ms 4596 KB Output is partially correct - number of calls to Secret by Init = 999, maximum number of calls to Secret by Query = 16