답안 #747212

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
747212 2023-05-23T23:55:26 Z Markomafko972 비밀 (JOI14_secret) C++14
컴파일 오류
0 ms 0 KB
#include "secret.h"
#include <bits/stdc++.h>
 
int n;
int a[1005];
int val[1005][1005];
vector<int> v[1005];
int maxid = 0;
int kol = 0;
 
// 4: 0 1 2 3 
 
void rek(int l, int r, int d) {
	maxid = max(maxid, d);
	if (l+1 == r) {
		v[d].push_back(l);
		val[l][l] = a[l];
		return;
	}
	
	int mid = (l+r)/2;
	int tren = a[mid-1];
	for (int j = mid-2; j >= l; j--) {
		if (kol == 8000) assert(0);
		tren = Secret(tren, a[j]);
		kol++;
		val[j][mid-1] = tren;
	}
	tren = a[mid];
	for (int j = mid+1; j < r; j++) {
		if (kol == 8000) assert(0);
		tren = Secret(tren, a[j]);
		kol++;
		val[mid][j] = tren;
	}
	v[d].push_back(mid);
 
	rek(l, mid, d+1);
	rek(mid, r, d+1);
}
 
void Init(int N, int A[]) {
	n = N;
	memset(val, -1, sizeof val);
	for (int i = 0; i < n; i++) {
		a[i] = A[i];
		val[i][i] = a[i];
	}
	rek(0, n, 0);
}
 
int Query(int l, int r) {
	for (int i = 0; i <= maxid; i++) {
		for (int j = 0; j < v[i].size(); j++) {
			if (l <= v[i][j] && v[i][j] <= r) {
				if (val[v[i][j]][r] == -1 || (l <= v[i][j]-1 && val[l][v[i][j]-1] == -1)) assert(0);
				
				return 0;
				
				if (l <= v[i][j]-1) return Secret(val[l][v[i][j]-1], val[v[i][j]][r]);
				else return val[v[i][j]][r];
			}
		}
	}
	return -1;
}

Compilation message

secret.cpp:7:1: error: 'vector' does not name a type
    7 | vector<int> v[1005];
      | ^~~~~~
secret.cpp: In function 'void rek(int, int, int)':
secret.cpp:14:10: error: 'max' was not declared in this scope; did you mean 'std::max'?
   14 |  maxid = max(maxid, d);
      |          ^~~
      |          std::max
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from secret.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: 'std::max' declared here
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
secret.cpp:16:3: error: 'v' was not declared in this scope
   16 |   v[d].push_back(l);
      |   ^
secret.cpp:36:2: error: 'v' was not declared in this scope
   36 |  v[d].push_back(mid);
      |  ^
secret.cpp: In function 'int Query(int, int)':
secret.cpp:54:23: error: 'v' was not declared in this scope
   54 |   for (int j = 0; j < v[i].size(); j++) {
      |                       ^