답안 #738140

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
738140 2023-05-08T08:05:32 Z anusha777 비밀 (JOI14_secret) C++14
100 / 100
456 ms 12276 KB
#include "secret.h"
#include <bits/stdc++.h>
#define fast 			ios::sync_with_stdio(0); cin.tie(NULL);cout.tie(NULL)
#define sz(x)			(int)((x).size())
#define pb				push_back
#define vi				vector<int>
#define vb				vector<bool>
#define vvb				vector<vb>
#define pi				pair<int,int>
#define vpi				vector<pi>
#define vvi				vector<vi>
#define vc				vector<char>
#define all(x)			x.begin(), x.end()
#define rall(x)			x.rbegin(), x.rend()
#define pbb()			pop_back()
#define f				first
#define s				second
#define ll				long long
//#define int				long long
#define ull				unsigned long long
#define line               cout<<"_____________________________"<<endl;
#define hash                cout<<"################"<<endl;
#define forr(i, a, b)      for(int i=a; i<b; i++)
using namespace std;
const int N=1e5+1, mod=1e9+7, inf=1e18+1;
vvi ldp, rdp;
vi a;
int n;
void populate(int l, int r)
{
    if(l>=r) return;
    int m= (l+r)/2;
    // l....m || m+1......r
    for(int i=m+2; i<=r; i++) rdp[m+1][i]= Secret(rdp[m+1][i-1], a[i]);
    for(int i=m-1; i>=l; i--) ldp[m][i]= Secret(a[i], ldp[m][i+1]);
    populate(l, m);
    populate(m+1, r);
}
void Init(int m, int A[])
{
    n=m;
    ldp.resize(n, vi(n));
    rdp.resize(n, vi(n));
    a.resize(n);
    forr(i, 0, n) a[i]=ldp[i][i]=rdp[i][i]=A[i];
    populate(0, n-1);
}
int query(int lx, int rx, int l, int r)
{
    int mx= (lx+rx)/2;
    // lx.........mx||mx+1..........rx
    //....l.................r
    if(l<=mx and mx+1<=r) return Secret( ldp[mx][l], rdp[mx+1][r]);
    if(mx==r) return ldp[mx][l];
    if(l==mx+1) return rdp[mx+1][r];
    if(r<mx) return query(lx, mx, l, r);
    return query(mx+1, rx,l, r);
}
int Query(int l, int r)
{
    if(l==r) return a[l];
    return query(0, n-1, l, r);
}

Compilation message

secret.cpp:25:39: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   25 | const int N=1e5+1, mod=1e9+7, inf=1e18+1;
      |                                   ~~~~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 124 ms 4360 KB Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1
2 Correct 129 ms 4460 KB Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1
3 Correct 126 ms 4444 KB Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1
4 Correct 447 ms 12060 KB Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1
5 Correct 456 ms 12076 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
6 Correct 430 ms 12116 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
7 Correct 437 ms 12180 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
8 Correct 430 ms 12276 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
9 Correct 430 ms 12184 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
10 Correct 433 ms 12092 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1