Submission #54651

#TimeUsernameProblemLanguageResultExecution timeMemory
54651red1108Secret (JOI14_secret)C++17
30 / 100
738 ms4704 KiB
#include <stdio.h> #include <algorithm> #include "secret.h" using namespace std; int seg[10000], si=1; void Init(int N, int A[]) { int input[2000],i; while(si<N) si*=2; for(i=N;i>=1;i--) { input[i]=A[i-1]; } for(i=1;i<=si*4;i++) seg[i]=123456789; for(i=si+N-1;i>=si;i--) { seg[i]=input[i-si+1]; } for(i=si-1;i>=1;i--) { if(seg[i*2]==123456789)seg[i]=123456789; else if(seg[i*2+1]==123456789)seg[i]=seg[i*2]; else seg[i]=Secret(seg[i*2],seg[i*2+1]); } } int query(int x, int l, int r, int s, int e) { int mid, left, right; if(r<s||l>e||l>r) return 123456789; if(s<=l&&r<=e) return seg[x]; left=query(x*2, l,(l+r)/2,s,e); right=query(x*2+1, ((l+r)/2)+1,r, s, e); if(left==123456789&&right==123456789) return 123456789; else if(right==123456789) return left; else if(left==123456789) return right; else return Secret(left, right); } int Query(int L, int R) { L++; R++; return query(1,1,si,L, R); }

Compilation message (stderr)

secret.cpp: In function 'int query(int, int, int, int, int)':
secret.cpp:29:9: warning: unused variable 'mid' [-Wunused-variable]
     int mid, left, right;
         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...