답안 #25335

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
25335 2017-06-21T07:56:43 Z dotorya 비밀 (JOI14_secret) C++14
100 / 100
626 ms 6644 KB
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

#include "secret.h"

int AA[1050];
map <int, int> Mx1[1050];
map <int, int> Mx2[1050];
int mySecret(int a, int b) {
	if (a == -1) return b;
	if (b == -1) return a;
	return Secret(a, b);
}
void Init(int N, int A[]) {
	int i, j;
	for (i = 1; i <= N; i++) AA[i] = A[i - 1];
	for (i = N; i >= 1; i--) {
		int prv = -1;
		for (j = i; j <= N; j += j & (-j)) {
			if (i == j) Mx1[i][i] = A[i-1];
			else {
				if (!Mx1[prv + 1].count(j)) printf("FUCKED\n");
				Mx1[i][j] = mySecret(Mx1[i][prv], Mx1[prv + 1][j]);
			}
			prv = j;
		}
	}
	for (i = 1; i <= N; i++) {
		int prv = -1;
		for (j = i; j; j -= j & (-j)) {
			if (i == j) Mx2[i][j] = -1;
			else if (j + 1 == i) Mx2[i][j] = A[i - 1];
			else {
				if (!Mx2[prv].count(j)) {
					if (!Mx1[j + 1].count(prv)) printf("FUCKED\n");
					Mx2[prv][j] = Mx1[j + 1][prv];
				}
				Mx2[i][j] = mySecret(Mx2[prv][j], Mx2[i][prv]);
			}
			prv = j;
		}
	}
}

int Query(int L, int R) {
	L++, R++;
	if (L == R) return AA[L];
	
	for (auto it : Mx1[L]) {
		if (Mx2[R].count(it.first)) return mySecret(Mx1[L][it.first], Mx2[R][it.first]);
	}
	printf("FUCKED\n");
	return 0;
}

Compilation message

secret.cpp:23:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
 #pragma warning(disable:4996)  
 ^
secret.cpp:24:0: warning: ignoring #pragma comment  [-Wunknown-pragmas]
 #pragma comment(linker, "/STACK:336777216")  
 ^
# 결과 실행 시간 메모리 Grader output
1 Correct 179 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 189 ms 6380 KB Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1
3 Correct 169 ms 6380 KB Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1
4 Correct 606 ms 6644 KB Output is correct - number of calls to Secret by Init = 6997, maximum number of calls to Secret by Query = 1
5 Correct 603 ms 6644 KB Output is correct - number of calls to Secret by Init = 7008, maximum number of calls to Secret by Query = 1
6 Correct 619 ms 6644 KB Output is correct - number of calls to Secret by Init = 7008, maximum number of calls to Secret by Query = 1
7 Correct 606 ms 6644 KB Output is correct - number of calls to Secret by Init = 7008, maximum number of calls to Secret by Query = 1
8 Correct 619 ms 6644 KB Output is correct - number of calls to Secret by Init = 7008, maximum number of calls to Secret by Query = 1
9 Correct 626 ms 6644 KB Output is correct - number of calls to Secret by Init = 7008, maximum number of calls to Secret by Query = 1
10 Correct 613 ms 6644 KB Output is correct - number of calls to Secret by Init = 7008, maximum number of calls to Secret by Query = 1