답안 #21122

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
21122 2017-04-04T18:18:42 Z sbansalcs 비밀 (JOI14_secret) C++14
0 / 100
606 ms 13860 KB
#include "secret.h"
#include <iostream>

#include <vector>
const int N = 1002;
using namespace std;

// vector<int> vt[N];
int val[N][N];
int hav[N][N];
int X[N];

void comp(int a, int b)  {
    if(a>=b)    return ;
    if(b-a==1)  {
    	hav[a][b]=1;
    	val[a][b]=Secret(X[a],X[b]);
    }
    else    {
        int f=(a+b)/2;
        int f2=f+1;
        for(int i=f-1;i>=a;i--)	{
        	hav[i][f]=1;
        	if(i==f-1)	val[i][f]=Secret(X[i],X[f]);
        	else	val[i][f]=Secret(X[i],val[i+1][f]);
        }
        f++;
        for(int i=f+1;i<=b;i++)	{
        	hav[f][i]=1;
        	if(i==f+1)	val[f][i]=Secret(X[i],X[f]);
        	else	val[f][i]=Secret(X[i],val[f][i-1]);
        }
        if(hav[f][f2]==0)	{
        	hav[f][f2]=1;
        	val[f][f2]=Secret(X[f],X[f2]);
        }

        comp(a,f-1);
        comp(f2+1,b);
    }
}


void Init(int N, int A[]) {
  // Secret(0, 1000000000);
	for(int i=1;i<=N;i++)	X[i]=A[i-1];
	for(int i=1;i<=N;i++)	{
		hav[i][i]=1;
		val[i][i]=X[i];
	}
	comp(1,N);
}

int Query(int L, int R) {
	L++,R++;
	if(L==R)	return X[L];
	else if(hav[L][R])	return val[L][R];
	for(int i=L;i<=R-1;i++)	{
		if(hav[L][i] && hav[i+1][R])	return Secret(val[L][i],val[i+1][R]);
	}
	// cout<<"shit!\n";
  return -1;
}

Compilation message


# 결과 실행 시간 메모리 Grader output
1 Incorrect 153 ms 13860 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 21455173.
2 Incorrect 153 ms 13860 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 68749376.
3 Incorrect 163 ms 13860 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 136349820.
4 Incorrect 603 ms 13860 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 650789536.
5 Incorrect 583 ms 13860 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 16813134.
6 Incorrect 596 ms 13860 KB Wrong Answer: Query(200, 208) - expected : 277813445, actual : 413587580.
7 Incorrect 606 ms 13860 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 687550570.
8 Incorrect 586 ms 13860 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 145923264.
9 Incorrect 589 ms 13860 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 18757135.
10 Incorrect 589 ms 13860 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 70590726.