답안 #362263

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
362263 2021-02-02T12:24:38 Z denkendoemeer 비밀 (JOI14_secret) C++14
100 / 100
539 ms 8556 KB
#include "secret.h"
#include<bits/stdc++.h>
int ans[1005][1005];
void calc(int st,int dr)
{
    int mij=(st+dr)/2,i;
    if (st==dr || st==dr-1)
        return ;
    for(i=mij-1;i>=st;i--)
        if (ans[i][mij]==-1)
            ans[i][mij]=Secret(ans[i][i+1],ans[i+1][mij]);
    for(i=mij+1;i<=dr;i++)
        if (ans[mij][i]==-1)
            ans[mij][i]=Secret(ans[mij][i-1],ans[i-1][i]);
    calc(st,mij);
    calc(mij,dr);
}
void Init(int n,int a[])
{
    int i,j;
    memset(ans,-1,sizeof(ans));
    for(i=0;i<n;i++)
        ans[i][i+1]=a[i];
    calc(0,n);
}
int Query(int l,int r)
{
    int i;
    for(i=l+1;i<=r;i++)
        if (ans[l][i]!=-1 && ans[i][r+1]!=-1)
            return Secret(ans[l][i],ans[i][r+1]);
    return ans[l][r+1];
}

Compilation message

secret.cpp: In function 'void Init(int, int*)':
secret.cpp:20:11: warning: unused variable 'j' [-Wunused-variable]
   20 |     int i,j;
      |           ^
# 결과 실행 시간 메모리 Grader output
1 Correct 144 ms 6380 KB Output is correct - number of calls to Secret by Init = 3084, maximum number of calls to Secret by Query = 1
2 Correct 144 ms 6508 KB Output is correct - number of calls to Secret by Init = 3092, maximum number of calls to Secret by Query = 1
3 Correct 150 ms 6380 KB Output is correct - number of calls to Secret by Init = 3101, maximum number of calls to Secret by Query = 1
4 Correct 509 ms 8300 KB Output is correct - number of calls to Secret by Init = 6989, maximum number of calls to Secret by Query = 1
5 Correct 527 ms 8300 KB Output is correct - number of calls to Secret by Init = 6997, maximum number of calls to Secret by Query = 1
6 Correct 506 ms 8428 KB Output is correct - number of calls to Secret by Init = 6997, maximum number of calls to Secret by Query = 1
7 Correct 539 ms 8428 KB Output is correct - number of calls to Secret by Init = 6997, maximum number of calls to Secret by Query = 1
8 Correct 515 ms 8556 KB Output is correct - number of calls to Secret by Init = 6997, maximum number of calls to Secret by Query = 1
9 Correct 509 ms 8556 KB Output is correct - number of calls to Secret by Init = 6997, maximum number of calls to Secret by Query = 1
10 Correct 520 ms 8300 KB Output is correct - number of calls to Secret by Init = 6997, maximum number of calls to Secret by Query = 1