답안 #217202

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
217202 2020-03-29T08:42:50 Z tselmegkh 비밀 (JOI14_secret) C++14
0 / 100
538 ms 8440 KB
#include<bits/stdc++.h>
#include "secret.h"
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 1e5 + 5, inf = 1e9;
#define pb push_back
#define mp make_pair
#define ll long long
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define sz(x) (int)x.size()
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int ans[1005][1005];

void solve(int l, int r){
	if(l == r){
		return;
	}
	int mid = (l + r) / 2;
	for(int i = mid - 1; i >= l; i--){
		ans[i][mid] = Secret(ans[i][i], ans[i + 1][mid]);
	}
	for(int i = mid + 2; i <= r; i++){
		ans[mid + 1][i] = Secret(ans[mid + 1][i - 1], ans[i][i]);
	}
	solve(l, mid);
	solve(mid + 1, r);
}
void Init(int n, int a[]){
	memset(ans, -1, sizeof ans);
	for(int i = 0; i < n; i++){
		ans[i][i] = Secret(a[i], a[i]);
	}
	solve(0, n - 1);
}
int Query(int ql, int qr){
	if(ans[ql][qr] != -1)return ans[ql][qr];
	for(int i = ql; i < qr; i++){
		if(ans[ql][i] != -1 && ans[i + 1][qr] != -1){
			return Secret(ans[ql][i], ans[i + 1][qr]);
		}
	}
}

Compilation message

secret.cpp: In function 'int Query(int, int)':
secret.cpp:54:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 145 ms 6392 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 856108439.
2 Incorrect 144 ms 6392 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 773568680.
3 Incorrect 142 ms 6392 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 605260104.
4 Incorrect 527 ms 8312 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 813924568.
5 Incorrect 516 ms 8312 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 523914330.
6 Incorrect 522 ms 8344 KB Wrong Answer: Query(915, 915) - expected : 282904741, actual : 31281100.
7 Incorrect 520 ms 8440 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 104891401.
8 Incorrect 515 ms 8184 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 202519744.
9 Incorrect 527 ms 8440 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 810557836.
10 Incorrect 538 ms 8440 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 807275528.