답안 #166520

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
166520 2019-12-02T16:57:23 Z losmi247 비밀 (JOI14_secret) C++14
0 / 100
627 ms 8444 KB
#include <bits/stdc++.h>
#include "secret.h"
using namespace std;
typedef long long ll;
typedef pair <int,int> p;
const int N = 1005;

int n,a[N];
int x[N][N];
bool imam[N];

/*int Secret(int a,int b){
    cout << a << " " << b << endl;
    int r;
    cin >> r;
    return r;
}*/

void nesto(int l,int r){
    int mid = l+(r-l)/2;
    if(mid >= r || mid < l){
        return;
    }
    x[mid][mid] = a[mid];
    x[mid+1][mid+1] = a[mid+1];
    imam[mid] = 1;
    for(int i = mid-1; i >= l; i--){
        x[i][mid] = Secret(a[i],x[i+1][mid]);
    }
    for(int i = mid+2; i <= r; i++){
        x[mid+1][i] = Secret(x[mid+1][i-1],a[i]);
    }
    nesto(l,mid);
    nesto(mid+1,r);
}

int Query(int l,int r){
    if(l == r){
        return a[l];
    }
    if(l+1 == r){
        return Secret(a[l],a[r]);
    }
    int pos = 0;
    for(int i = l; i <= r; i++){
        if(imam[i]){
            pos = i;
            break;
        }
    }
    /*cout << "naso " << pos << endl;
    cout << "to su " << x[l][pos] << " " << x[pos+1][r] << endl;*/
    return Secret(x[l][pos],x[pos+1][r]);
}

void Init(int l,int d[]){
    n = l;
    for(int i = 1; i <= n; i++){
        a[i] = d[i-1];
    }
    nesto(1,n);
    /*cout << "eve " << endl;
    for(int i = 1; i <= n; i++){
        for(int j = i; j <= n; j++){
            cout << i << " " << j << " " << x[i][j] << endl;
        }
    }
    cout << endl;*/
}

/*int main(){
    int a[4] = {1,2,3,4};
    Init(4,a);
    cout << Query(2,4) << endl;
    cout << Query(1,3) << endl;
    cout << Query(1,4) << endl;
}*/
# 결과 실행 시간 메모리 Grader output
1 Incorrect 164 ms 4472 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 395008.
2 Incorrect 163 ms 4616 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 522205472.
3 Incorrect 173 ms 4548 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 562321514.
4 Incorrect 598 ms 8440 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 390709948.
5 Incorrect 627 ms 8444 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 955944192.
6 Incorrect 604 ms 8440 KB Wrong Answer: Query(915, 915) - expected : 282904741, actual : 579799611.
7 Incorrect 600 ms 8312 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 110146595.
8 Incorrect 604 ms 8320 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 89138432.
9 Incorrect 611 ms 8408 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 9711111.
10 Incorrect 604 ms 8360 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 276384642.