Submission #65534

# Submission time Handle Problem Language Result Execution time Memory
65534 2018-08-07T21:34:16 Z reality Secret (JOI14_secret) C++17
100 / 100
661 ms 8680 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 = m - 1;i >= l;--i)
		if (G[i][m] == -1)
			G[i][m] = Secret(G[i][i],G[i + 1][m]);
	for (int i = m + 2;i <= r;++i)
		if (G[m + 1][i] == -1) 
			G[m + 1][i] = Secret(G[m + 1][i - 1],G[i][i]);
}

void Init(int N, int A[]) {
	n = N;
	for (int i = 0;i < n;++i)
		for (int j = i + 1;j < n;++j)
			G[i][j] = -1;
	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 Secret(G[L][k],G[k + 1][R]);
}

Compilation message

secret.cpp: In function 'int Query(int, int)':
secret.cpp:57:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Correct 190 ms 4500 KB Output is correct - number of calls to Secret by Init = 3084, maximum number of calls to Secret by Query = 1
2 Correct 185 ms 4504 KB Output is correct - number of calls to Secret by Init = 3092, maximum number of calls to Secret by Query = 1
3 Correct 178 ms 4508 KB Output is correct - number of calls to Secret by Init = 3101, maximum number of calls to Secret by Query = 1
4 Correct 629 ms 8476 KB Output is correct - number of calls to Secret by Init = 6989, maximum number of calls to Secret by Query = 1
5 Correct 639 ms 8476 KB Output is correct - number of calls to Secret by Init = 6997, maximum number of calls to Secret by Query = 1
6 Correct 639 ms 8512 KB Output is correct - number of calls to Secret by Init = 6997, maximum number of calls to Secret by Query = 1
7 Correct 646 ms 8576 KB Output is correct - number of calls to Secret by Init = 6997, maximum number of calls to Secret by Query = 1
8 Correct 644 ms 8576 KB Output is correct - number of calls to Secret by Init = 6997, maximum number of calls to Secret by Query = 1
9 Correct 641 ms 8576 KB Output is correct - number of calls to Secret by Init = 6997, maximum number of calls to Secret by Query = 1
10 Correct 661 ms 8680 KB Output is correct - number of calls to Secret by Init = 6997, maximum number of calls to Secret by Query = 1