Submission #65522

# Submission time Handle Problem Language Result Execution time Memory
65522 2018-08-07T20:30:00 Z reality Secret (JOI14_secret) C++17
0 / 100
20000 ms 9896 KB
#include "secret.h"

#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class P , class Q > ostream& operator<<(ostream& stream, pair < P , Q > v){ stream << "(" << v.fi << ',' << v.se << ")"; return stream;}
template < class T > ostream& operator<<(ostream& stream, const vector<T> v){ stream << "[ "; for (int i=0; i<(int)v.size(); i++) stream << v[i] << " "; stream << "]"; return stream;}
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}

const int NN = 1024;

int G[NN][NN];

int n;

void go(int l,int r) {
	if (l == r)
		return;
	int m = (l + r) / 2;
	go(l,m);
	go(m+1,r);
	for (int i = l;i >= 0;--i)
		if (G[i][m + 1] == -1) {
			for (int t = i;t <= m;++t)
				if (G[i][t] != -1 && G[t + 1][m + 1] != -1)
					G[i][m + 1] = Secret(G[i][t],G[t + 1][m + 1]);
		}
	for (int i = m + 1;i <= r;++i)
		if (G[m][i] == -1) {
			for (int t = m;t < i;++t)
				if (G[m][t] != -1 && G[t + 1][i] != -1)
					G[m][i] = Secret(G[m][t],G[t + 1][i]);
		}

}

void Init(int N, int A[]) {
	int n = N;
	memset(G,-1,sizeof(G));
	for (int i = 0;i < n;++i)
		G[i][i] = A[i];
	go(0,n - 1);
}

int Query(int L, int R) {
	if (G[L][R] != -1)
		return G[L][R];
	for (int k = L;k < R;++k)
		if (G[L][k] != -1 && G[k + 1][R] != -1)
			return G[L][R] = Secret(G[L][k],G[k + 1][R]);
}

Compilation message

secret.cpp: In function 'int Query(int, int)':
secret.cpp:62:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Execution timed out 20059 ms 6776 KB Time limit exceeded
2 Execution timed out 20017 ms 6960 KB Time limit exceeded
3 Execution timed out 20039 ms 7116 KB Time limit exceeded
4 Execution timed out 20025 ms 9192 KB Time limit exceeded
5 Execution timed out 20079 ms 9484 KB Time limit exceeded
6 Execution timed out 20065 ms 9516 KB Time limit exceeded
7 Execution timed out 20082 ms 9608 KB Time limit exceeded
8 Execution timed out 20102 ms 9712 KB Time limit exceeded
9 Execution timed out 20007 ms 9896 KB Time limit exceeded
10 Execution timed out 20058 ms 9896 KB Time limit exceeded