답안 #307818

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
307818 2020-09-29T10:57:51 Z syy 비밀 (JOI14_secret) C++17
0 / 100
505 ms 8576 KB
#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
typedef pair<pi, int> pii;
typedef pair<pi, pi> pipi;
#define f first
#define s second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define disc(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
#define INF (int) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sandybridge __attribute__((optimize("Ofast"), target("arch=sandybridge")))
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss

int n, res[1005][1005];

void dnc(int s, int e) {
	if (s == e) return;
	int mid = (s+e)/2;
	DEC(i, mid-1, s) if (res[i][mid] == -1) res[i][mid] = Secret(res[i][i], res[i+1][mid]);
	FOR(i, mid+1, e) if (res[mid+1][i] == -1) res[mid+1][i] = Secret(res[i][i], res[mid+1][i-1]);
	dnc(s, mid);
	dnc(mid+1, e);
}

void Init(int N, int A[]) {
	n = N;
	memset(res, -1, sizeof res);
	FOR(i, 0, n-1) res[i][i] = A[i];
	dnc(0, n-1);
}

int Query(int l, int r) {
	if (res[l][r] != -1) return res[l][r];
	FOR(i, l, r-1) if (res[l][i] != -1 and res[i+1][r] != -1) return Secret(res[l][i], res[i+1][r]);
}

Compilation message

secret.cpp: In function 'int Query(int, int)':
secret.cpp:48:1: warning: control reaches end of non-void function [-Wreturn-type]
   48 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 137 ms 6392 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 809782271.
2 Incorrect 135 ms 6520 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 68749376.
3 Incorrect 134 ms 6520 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 136349820.
4 Incorrect 495 ms 8440 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 650789536.
5 Incorrect 496 ms 8440 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 377506838.
6 Incorrect 502 ms 8440 KB Wrong Answer: Query(738, 741) - expected : 983692994, actual : 61461050.
7 Incorrect 504 ms 8440 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 687550570.
8 Incorrect 497 ms 8440 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 145923264.
9 Incorrect 499 ms 8576 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 18757135.
10 Incorrect 505 ms 8440 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 70590726.