Submission #243231

# Submission time Handle Problem Language Result Execution time Memory
243231 2020-06-30T15:30:18 Z Rainbowbunny Secret (JOI14_secret) C++17
0 / 100
788 ms 524292 KB
#include <bits/stdc++.h>
#include "secret.h"
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using cd = complex <double>;
 
typedef pair <int, int> pii;
 
const int Inf = 2e9;
const int mod = 998244353;
const double Pi = acos(-1);
 
void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int n;
int a[1005];
int Table[1005][1005];

void Create(int l, int r)
{
	if(r - l == 1)
	{
		return;
	}	
	int mid = (l + r) >> 1;
	for(int i = mid - 1; i >= l; i--)
	{
		Table[i][mid] = Secret(a[i], Table[i + 1][mid]);
	}
	for(int i = r - 1; i >= mid + 1; i--)
	{
		Table[i][r] = Secret(a[i], Table[i + 1][r]);
	}
	Create(l, mid);
	Create(mid + 1, r);
}

void Init(int N, int b[])
{
	n = N;
	for(int i = 0; i < n; i++)
	{
		a[i] = b[i];
		for(int j = 0; j < n; j++)
		{
			Table[i][j] = Inf;
		}
		Table[i][i] = a[i];
	}
	Create(0, n - 1);
}

int Query(int l, int r)
{
	if(r == l)
	{
		return a[r];
	}
	else if(r - l == 1)
	{
		return Secret(a[l], a[l + 1]);
	}
	else
	{  
		if(Table[l][r] != Inf)
		{
			return Table[l][r];
		}
		for(int i = l; i <= r; i++)
		{
			if(Table[l][i] != Inf and Table[i + 1][r] != Inf)
			{
				return Secret(Table[l][i], Table[i + 1][r]);
			}
		}
	}
}

Compilation message

secret.cpp: In function 'int Query(int, int)':
secret.cpp:85:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Runtime error 419 ms 524288 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Incorrect 138 ms 4472 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 376.
3 Runtime error 431 ms 524288 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Runtime error 788 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
5 Runtime error 774 ms 524288 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Runtime error 771 ms 524288 KB Execution killed with signal 9 (could be triggered by violating memory limits)
7 Runtime error 785 ms 524288 KB Execution killed with signal 9 (could be triggered by violating memory limits)
8 Runtime error 777 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
9 Runtime error 786 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Runtime error 783 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)