Submission #935573

# Submission time Handle Problem Language Result Execution time Memory
935573 2024-02-29T09:24:24 Z Baizho Secret (JOI14_secret) C++14
0 / 100
395 ms 8528 KB
#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
  
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
 
// #pragma GCC optimize("Ofast,unroll-loops,fast-math")
// #pragma GCC target("popcnt")
 
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
 
#define sz size()
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define pb push_back
 
const int mod = ll(1e9)+7;
const ll MOD = 998244353;
const long long inf = 5e18;
const int M = 1005;

int Secret(int x, int y);

int val[M][M], n, a[M];

void solve(int l, int r) {
	if(l > r) return;
	if(l == r) {
		val[l][r] = a[l];
		return;
	}
	int mid = (l + r) / 2;
	val[mid][mid] = a[mid];
	val[mid + 1][mid + 1] = a[mid + 1];
	for(int i = mid - 1; i >= l; i --) val[i][mid] = Secret(val[i + 1][mid], a[i]);
	for(int i = mid + 2; i <= r; i ++) val[mid + 1][i] = Secret(val[mid + 1][i - 1], a[i]);
	solve(l, mid - 1); solve(mid + 2, r);
}

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

int Query(int L, int R) {
	int l = L, r = R, tl = 0, tr = n - 1;
	if(l == r) return a[l];
	while(tl <= tr) {
		int mid = (tl + tr) / 2;
		if(l <= mid && mid + 1 <= r) return Secret(val[l][mid], val[mid + 1][r]);
		else if(r < mid) tr = mid - 1;
		else tl = mid + 2; 
	}
}

Compilation message

secret.cpp: In function 'int Query(int, int)':
secret.cpp:63:1: warning: control reaches end of non-void function [-Wreturn-type]
   63 | }
      | ^
# Verdict Execution time Memory Grader output
1 Incorrect 101 ms 6740 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 268854015.
2 Incorrect 100 ms 6828 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 311474560.
3 Incorrect 103 ms 6908 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 353554500.
4 Incorrect 371 ms 8528 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 343081568.
5 Incorrect 395 ms 8372 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 497583184.
6 Incorrect 374 ms 8368 KB Wrong Answer: Query(738, 741) - expected : 983692994, actual : 302576192.
7 Incorrect 378 ms 8364 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 675449873.
8 Incorrect 381 ms 8280 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 273091792.
9 Incorrect 376 ms 8364 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 827853577.
10 Incorrect 372 ms 8276 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 337854787.