Submission #293263

# Submission time Handle Problem Language Result Execution time Memory
293263 2020-09-07T20:06:24 Z RedNextCentury Secret (JOI14_secret) C++14
0 / 100
533 ms 9080 KB
#include "secret.h"
#include<bits/stdc++.h>
using namespace std;
vector<int> centers;
vector<int> start, finish;
int val[2002][2002];
int a[2002];
int num=0;
//int Secret(int l,int r){return 0;}
void DC(int L,int R) {
    if (L>R) return;
    else {
        int mid = (L+R)/2;
        centers.push_back(mid);
        start.push_back(L);
        finish.push_back(R);
        val[mid][mid]=a[mid];
        for (int i=mid-1;i>=L;i--) val[i][mid] = Secret(a[i], val[i+1][mid]);
        val[mid+1][mid+1]=a[mid];
        for (int i=mid+2;i<=R;i++) val[mid+1][i] = Secret(val[mid+1][i-1], a[i]);
        DC(L, mid-1);
        DC(mid+1,R);
    }
}

void Init(int N, int A[]) {
    for (int i=0;i<N;i++) a[i] = A[i];
    DC(0, N-1);
}

int Query(int L, int R) {
  for (int i=0;i<centers.size();i++) {
    if (start[i]<=L && finish[i]>=R && centers[i]<=R && centers[i]>=L) {
        if (L==centers[i]+1 || R==centers[i]) return val[L][R];
        return Secret(val[L][centers[i]], val[centers[i]+1][R]);
    }
  }
}

Compilation message

secret.cpp: In function 'int Query(int, int)':
secret.cpp:32:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |   for (int i=0;i<centers.size();i++) {
      |                ~^~~~~~~~~~~~~~~
secret.cpp:38:1: warning: control reaches end of non-void function [-Wreturn-type]
   38 | }
      | ^
# Verdict Execution time Memory Grader output
1 Incorrect 133 ms 4728 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 570506607.
2 Incorrect 136 ms 4728 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 552147169.
3 Incorrect 138 ms 4600 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 486861108.
4 Incorrect 498 ms 9056 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 600440873.
5 Incorrect 497 ms 9080 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 711464990.
6 Incorrect 497 ms 9016 KB Wrong Answer: Query(915, 915) - expected : 282904741, actual : 579799611.
7 Incorrect 533 ms 9036 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 743153696.
8 Incorrect 519 ms 9048 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 421960072.
9 Incorrect 495 ms 8952 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 433988643.
10 Incorrect 497 ms 9080 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 876144393.