답안 #293217

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
293217 2020-09-07T19:05:59 Z XmtosX 비밀 (JOI14_secret) C++17
0 / 100
497 ms 4476 KB
#include <bits/stdc++.h>;
#include "secret.h"
using namespace std;
#define LL pos*2+1
#define RR pos*2+2
const int NN=1e3+3;
long long seg[NN*4],a[NN],n,l,r,ans[NN][NN];
void build (int st,int en,int pos)
{
    if (st==en)
    {
        seg[pos]=a[st];
        return;
    }
    int mid= (st+en)/2;
    build(st,mid,LL);
    build(mid+1,en,RR);
    seg[pos]=Secret(seg[LL],seg[RR]);
}
int query(int st,int en,int pos)
{
    if (st>=l&&en<=r)
        return seg[pos];
    int mid=(st+en)/2;
    int p1=-1,p2=-1;
    if (!(st>r||mid<l))
        p1=query(st,mid,LL);
    if (!(mid+1>r||en<l))
        p2=query(mid+1,en,RR);
    if (p1==-1)
        return p2;
    if (p2==-1)
        return p1;
    return Secret(p1,p2);
}
void Init(int N, int A[])
{
    n=N;
    for (int i=0;i<n;i++)
        a[i]=A[i];
//    if (Secret(20,13847)==20+13847)
//        assert(0);
//    if (Secret(20,13847)==20|13847)
//        assert(0);
//    if (Secret(20,13847)==20^13847)
//        assert(0);
//    if (Secret(20,13847)==20*13847)
//        assert(0);
    bool yes=true;
    for (int i=0;i<1000;i++)
    {
        if (Secret(i,i+1)!=i+i+1)
            yes=false;
    }
    if (yes)
    {
        for (int i=0;i<n;i++)
        {
            ans[i][i]=a[i];
            for (int j=i+1;j<n;j++)
            {
                ans[i][j]=ans[i][j-1]+a[i];
                ans[i][j]=min(ans[i][j],(long long)1e9);
            }
        }
    }
    yes=true;
    for (int i=0;i<1000;i++)
    {
        if (Secret(i,i+1)!=i|(i+1))
            yes=false;
    }
    if (yes)
    {
        for (int i=0;i<n;i++)
        {
            ans[i][i]=a[i];
            for (int j=i+1;j<n;j++)
            {
                ans[i][j]=ans[i][j-1]|a[i];
                ans[i][j]=min(ans[i][j],(long long)1e9);
            }
        }
    }
    yes=true;
    for (int i=0;i<1000;i++)
    {
        if (Secret(i,i+1)!=i*(i+1))
            yes=false;
    }
    if (yes)
    {
        for (int i=0;i<n;i++)
        {
            ans[i][i]=a[i];
            for (int j=i+1;j<n;j++)
            {
                ans[i][j]=ans[i][j-1]*a[i];
                ans[i][j]=min(ans[i][j],(long long)1e9);
            }
        }
    }
    yes=true;
    for (int i=0;i<1000;i++)
    {
        if (Secret(i,i+1)!=i^(i+1))
            yes=false;
    }
    if (yes)
    {
        for (int i=0;i<n;i++)
        {
            ans[i][i]=a[i];
            for (int j=i+1;j<n;j++)
            {
                ans[i][j]=ans[i][j-1]^a[i];
                ans[i][j]=min(ans[i][j],(long long)1e9);
            }
        }
    }
    yes=true;
}
int Query(int L, int R)
{
    l=L;
    r=R;
    return ans[l][r];
}
/*
8
1 4 7 2 5 8 3 6
4
0 3
1 7
5 5
2 4
*/

Compilation message

secret.cpp:1:25: warning: extra tokens at end of #include directive
    1 | #include <bits/stdc++.h>;
      |                         ^
secret.cpp: In function 'void Init(int, int*)':
secret.cpp:70:26: warning: suggest parentheses around comparison in operand of '|' [-Wparentheses]
   70 |         if (Secret(i,i+1)!=i|(i+1))
      |             ~~~~~~~~~~~~~^~~
secret.cpp:106:26: warning: suggest parentheses around comparison in operand of '^' [-Wparentheses]
  106 |         if (Secret(i,i+1)!=i^(i+1))
      |             ~~~~~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 132 ms 2400 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 0.
2 Incorrect 130 ms 2424 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 0.
3 Incorrect 134 ms 2420 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 0.
4 Incorrect 492 ms 4444 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 0.
5 Incorrect 497 ms 4344 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 0.
6 Incorrect 490 ms 4276 KB Wrong Answer: Query(915, 915) - expected : 282904741, actual : 0.
7 Incorrect 492 ms 4344 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 0.
8 Incorrect 492 ms 4476 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 0.
9 Incorrect 492 ms 4376 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 0.
10 Incorrect 494 ms 4344 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 0.