답안 #239870

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
239870 2020-06-17T12:32:44 Z MvC 비밀 (JOI14_secret) C++11
100 / 100
521 ms 8568 KB
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include "secret.h"
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
#define all(x) x.begin(),x.end()
#define lun(x) (int)x.size()
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<60);
const int inf=(1<<30);
const int nmax=1e3+50;
const ll mod=1e9+7;
using namespace std;
int a[nmax],b[nmax][nmax];
void build(int l,int r)
{
	if(l>=r)return;
	if(l==r-1)
	{
		b[l][r]=Secret(a[l],a[r]);
		return;
	}
	int mid=(l+r)/2;
	for(int i=mid-1;i>=l;i--)if(b[i][mid]==-1)b[i][mid]=Secret(a[i],b[i+1][mid]);
	for(int i=mid+2;i<=r;i++)if(b[mid+1][i]==-1)b[mid+1][i]=Secret(b[mid+1][i-1],a[i]);
	build(l,mid);
	build(mid+1,r);
}
void Init(int n,int A[])
{
	for(int i=1;i<=n;i++)a[i]=A[i-1];
	for(int i=1;i<=n;i++)
	{
		for(int j=i;j<=n;j++)
		{
			if(i==j)b[i][i]=a[i];
			else b[i][j]=-1;
		}
	}
	build(1,n);
}
int Query(int l,int r)
{
	l++,r++;
	if(b[l][r]!=-1)return b[l][r];
	for(int i=l;i<r;i++)if(b[l][i]!=-1 && b[i+1][r]!=-1)return Secret(b[l][i],b[i+1][r]);
}
/*int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	
	return 0;
}*/

Compilation message

secret.cpp: In function 'int Query(int, int)':
secret.cpp:56:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# 결과 실행 시간 메모리 Grader output
1 Correct 154 ms 4632 KB Output is correct - number of calls to Secret by Init = 3339, maximum number of calls to Secret by Query = 1
2 Correct 153 ms 4472 KB Output is correct - number of calls to Secret by Init = 3348, maximum number of calls to Secret by Query = 1
3 Correct 151 ms 4728 KB Output is correct - number of calls to Secret by Init = 3357, maximum number of calls to Secret by Query = 1
4 Correct 513 ms 8432 KB Output is correct - number of calls to Secret by Init = 7476, maximum number of calls to Secret by Query = 1
5 Correct 521 ms 8500 KB Output is correct - number of calls to Secret by Init = 7485, maximum number of calls to Secret by Query = 1
6 Correct 517 ms 8568 KB Output is correct - number of calls to Secret by Init = 7485, maximum number of calls to Secret by Query = 1
7 Correct 517 ms 8440 KB Output is correct - number of calls to Secret by Init = 7485, maximum number of calls to Secret by Query = 1
8 Correct 518 ms 8452 KB Output is correct - number of calls to Secret by Init = 7485, maximum number of calls to Secret by Query = 1
9 Correct 509 ms 8440 KB Output is correct - number of calls to Secret by Init = 7485, maximum number of calls to Secret by Query = 1
10 Correct 510 ms 8568 KB Output is correct - number of calls to Secret by Init = 7485, maximum number of calls to Secret by Query = 1