답안 #376062

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
376062 2021-03-10T20:18:54 Z Leonardo_Paes 비밀 (JOI14_secret) C++17
0 / 100
1237 ms 24044 KB
#include "secret.h"
#include <bits/stdc++.h>

typedef std::pair<int,int> pii;
#define f first
#define s second
const int maxn = 1030;
int v[maxn], n;

std::map<pii, int> m;

class Seg{
public:
	int join(int a, int b){
		if(a == -1) return b;
		if(b == -1) return a;
		pii x = {a, b};
		return (m.find(x) != m.end() ? m[x] : m[x] = Secret(a, b));
	}
	void build(int node, int l, int r){
		if(l == r){
			tree[node] = v[l];
			return;
		}
		int mid = (l + r) >> 1;
		build(2*node, l, mid), build(2*node+1, mid+1, r);
		tree[node] = join(tree[2*node], tree[2*node+1]);
	}
	int query(int node, int tl, int tr, int l, int r){
		if(tl > r or tr < l) return -1;
		if(tl >= l and tr <= r) return tree[node];
		int mid = (tl + tr) >> 1;
		return join(query(2*node, tl, mid, l, r), query(2*node+1, mid+1, tr, l, r));
	}
private:
	int tree[2*maxn];
}seg;

void Init(int N, int A[]) {
	n = N;
	for(int i=1; i<=N; i++) v[i] = A[i-1];
	seg.build(1, 1, N); std::cout << "\n";
	for(int l=1; l<=N/2; l++){
		for(int r=l; r<=N/2; r++){
			std::cout << l << " " << r << "\n";
			std::cout << seg.query(1, 1, N, l, r) << "\n";
		}
	}
	for(int l=N/2+1; l<=N; l++){
		for(int r=l+1; r<=N; r++){
			std::cout << l << " " << r << "\n";
			seg.query(1, 1, N, l, r);
		}
	}
}

int Query(int L, int R) {
	L++, R++;
	return seg.query(1, 1, n, L, R);
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 309 ms 7788 KB Do not print anything to standard output
2 Incorrect 311 ms 7788 KB Do not print anything to standard output
3 Incorrect 314 ms 7788 KB Do not print anything to standard output
4 Incorrect 1219 ms 23592 KB Do not print anything to standard output
5 Incorrect 1232 ms 23788 KB Do not print anything to standard output
6 Incorrect 1164 ms 23532 KB Do not print anything to standard output
7 Incorrect 1220 ms 23788 KB Do not print anything to standard output
8 Incorrect 1216 ms 23944 KB Do not print anything to standard output
9 Incorrect 1237 ms 24044 KB Do not print anything to standard output
10 Incorrect 1229 ms 23976 KB Do not print anything to standard output