Submission #380499

# Submission time Handle Problem Language Result Execution time Memory
380499 2021-03-22T05:26:31 Z pure_mem Secret (JOI14_secret) C++14
0 / 100
537 ms 9468 KB
#include "secret.h"
#include <bits/stdc++.h>

#define X first
#define Y second
#define MP make_pair
#define ll long long

using namespace std;

int q[1001][1001];
bool was[1001][1001];
void Init(int N, int A[]) {
  	stack< pair<int, int> > st;
  	st.push(MP(1, N));
  	while(!st.empty()){
  		int l = st.top().X, r = st.top().Y; st.pop();
  		int m = (l + r) / 2;
  		was[m][m] = 1, q[m][m] = A[m - 1];
  		for(int i = m - 1, j = A[m - 1];i >= l;i--){
  			j = Secret(A[i - 1], j), q[i][m] = j, was[i][m] = 1;	
  		}
  		if(l == r)
  			continue;
  		was[m + 1][m + 1] = 1, q[m + 1][m + 1] = A[m];
  		for(int i = m + 2, j = A[m];i <= r;i++){
  			j = Secret(A[i - 1], j), q[m + 1][i] = j, was[m + 1][i] = 1;
  		}
  		if(l != r)
  			st.push(MP(l, m)), st.push(MP(m + 1, r));
  	}
  // Secret(0, 1000000000);
}

int Query(int L, int R) {
	L += 1, R += 1;
	if(was[L][R])
		return q[L][R];
	for(int i = L;i < R;i++){
		if(was[L][i] && was[i + 1][R])
			return Secret(q[L][i], q[i + 1][R]);
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 132 ms 5100 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 554110774.
2 Incorrect 134 ms 4972 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 68749376.
3 Incorrect 139 ms 4972 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 136349820.
4 Incorrect 490 ms 9276 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 650789536.
5 Incorrect 493 ms 9468 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 377506838.
6 Incorrect 512 ms 9324 KB Wrong Answer: Query(738, 741) - expected : 983692994, actual : 61461050.
7 Incorrect 493 ms 9324 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 687550570.
8 Incorrect 499 ms 9452 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 145923264.
9 Incorrect 537 ms 9408 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 18757135.
10 Incorrect 498 ms 9452 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 70590726.