prompt string | response string |
|---|---|
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
int n, i, j, l[2002], r[2002];
long double p, h, x[2002];
bool mark[2002][2002][2][2];
long double dp[2002][2002][2][2], z = 0.5;
void rec(int s, int e, int f1, int f2) {
if (mark[s][e][f1][f2]) return;
long double answ = 0;
mark[s][e][f1][f2] = true;
rec(s + 1, e, ... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class Main {
public static void main(String[] args) {
// Test.testing();
ConsoleIO io = new ConsoleIO();
new Main(io).solve();
io.flush();
}
ConsoleIO io;
... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
int n, x[2010];
double dp[2010][2010][2][2];
bool ok[2010][2010][2][2];
int pre[2010];
int h;
double p;
int nxt[2010];
double work(int l, int r, int fl, int fr) {
if (l > r) return 0;
if (ok[l][r][fl][fr]) return dp[l][r][fl][fr];
ok[l][r][fl][fr] = 1;
double ans = ... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
int n, h;
int x[2005], pr[2005], nt[2005];
double p;
double dp[2005][2005][2][2];
double calc(int l, int r, bool bl, bool br) {
if (l > r) return 0;
double &rlt = dp[l][r][bl][br];
if (rlt > 0) return rlt;
int ll = bl ? x[l - 1] + h : x[l - 1];
int rr = br ? x[r +... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
double dp[2007][2007][2][2];
int H;
double p;
vector<int> pos;
int knocks_l[2007];
int knocks_r[2007];
double left_tree_right(int lo, int hi, bool l, bool r);
double left_tree_left(int lo, int hi, bool l, bool r);
double right_tree_left(int lo, int hi, bool l, bool r);
doub... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
int n, h;
double p;
int x[2005], ld[2005], rd[2005];
double f[2005][2005][2][2];
int vis[2005][2005][2][2];
double dp(int i, int j, int z, int y) {
if (vis[i][j][z][y]) return f[i][j][z][y];
if (i > j) return 0;
double re = 0;
int h1 = min(h, x[i] - x[i - 1] - h * z... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
const int N = 2001;
int n, h, nxtLR[N], nxtRL[N];
long long v[N];
double p, dp[N][N][2][2];
double calc(int i, int j, bool tl, bool tr) {
if (i > j) return 0;
double &ret = dp[i][j][tl][tr];
if (ret == ret) return ret;
ret = 0;
if (i == j) {
long long com = !i... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
int n, h, x[2010], fall[2][2010];
double p, dp[2010][2010][2][2];
double solve(int l, int r, int fl, int fr) {
if (l > r) return 0;
if (dp[l][r][fl][fr] != -1) return dp[l][r][fl][fr];
dp[l][r][fl][fr] = 0;
double res = 0;
int nl = min(r, l + fall[0][l] - 1);
if... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
const double eps = 1e-8;
const int maxn = 2002;
const int maxm = 3e4 + 5;
const long long mod = 1e9 + 7;
const long long inf = 2e18 + 5;
const int _inf = -1e9 + 7;
inline int scan() {
int m = 0;
char c = getchar();
while (c < '0' || c > '9'... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
inline long long read() {
long long f = 1, x = 0;
char s = getchar();
while (s < '0' || s > '9') {
if (s == '-') f = -1;
s = getchar();
}
while (s >= '0' && s <= '9') {
x = x * 10 - '0' + s;
s = getchar();
}
return x * f... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
const int N = 2005;
int n, m, a[N], ml[N], cr[N];
double f[N][N][2][2], P;
inline double dfs(int l, int r, int opl, int opr) {
if (l > r) return 0;
if (f[l][r][opl][opr]) return f[l][r][opl][opr];
double sum = 0;
sum += 0.5 * P *
(std::min(m, a[l] - a[l - 1] - opl * m) + dfs(l ... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
using ld = long double;
using ul = unsigned long long;
using db = double;
using pi = pair<int, int>;
using pl = pair<long long, long long>;
using pd = pair<ld, ld>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<long long>>;
using vi = vector<int>;
using vb = ve... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
int n, h;
double p;
int was[2002][2002][2][2];
double mem[2002][2002][2][2];
int a[2222];
int nl[2222], nr[2222];
double go(int x, int y, int xx, int yy) {
int d = a[x - 1];
if (xx) d += h;
int xl = min(a[x] - d, h);
d = a[y + 1];
if (yy == 0) d -= h;
int yr = m... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;
public class D {
public static void main(String[] args) {
Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(
System.in)));
int n = sc.nextInt();
... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.Reader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
imp... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | import java.io.*;
import java.util.*;
public class D596 {
static int n, h;
static int[] xs, left, right;
static double p;
public static void main(String[] args) throws IOException {
input.init(System.in);
PrintWriter out = new PrintWriter(System.out);
n = input.nextInt();
h = input.nextInt()... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
template <typename T>
class heap : public priority_queue<T, vector<T>, greater<T> > {};
double memo[2047][2047][2][2];
vector<int> l;
vector<int> r;
vector<int> t;
double p;
int n, h;
int min(int a, int b) { return a < b ? a : b; }
double solve(int left, int right, int a, i... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | import java.io.*;
import java.util.*;
/**
* @auther chao
* @date 15/12/30
*/
public class MainApp {
static double[][][][] dp;
static int[] a;
static int[] R;
static int[] L;
static double p;
static int n;
static int h;
static final int LIMIT = 100000000;
public static void main... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 5;
int n;
double p, h;
double dp[N][N][2][2], pos[N];
int ll[N], rr[N];
inline void init() {
ll[1] = 1;
for (register int i = 2; i <= n; ++i)
if (pos[i] - pos[i - 1] < h)
ll[i] = ll[i - 1];
else
ll[i] = i;
rr[n] = n;
for (regi... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
int n, h, x, l, u, gn, t[4][2001][2001], pos[2002];
double p, values[4][2001][2001];
double dp(int prevl, int prevr, int lower, int upper) {
if (t[2 * prevl + prevr][lower][upper])
return values[2 * prevl + prevr][lower][upper];
int minp = pos[lower - 1], maxp = pos... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
int i, j, n, h;
double p;
int x[2010];
double q[2010][2010][4];
bool checked[2010][2010][4];
double mymin(double a, double b) { return a < b ? a : b; }
double make(int l, int r, int state) {
if (checked[l][r][state]) return q[l][r][state];
checked[l][r][state] = true;
... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
struct pokr {
double p1;
double p2;
double len;
pokr(double _p1, double _p2, double _l) : p1(_p1), p2(_p2), len(_l) {}
pokr() { p1 = p2 = len = 0; }
} d[2100][2100];
int x[2100];
int c[2100][2100];
int a[2100];
int b[2100];
double p, q;
int h;
pokr get_ans(int l, ... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
const int N = 2005;
double dp[N][N][2][2], p;
int L[N], R[N], X[N], h, n;
bool vis[N][N][2][2];
double dpit(int l, int r, int x, int y) {
int dis;
bool debug = l == 3 && r == 3;
if (l > r) return 0;
if (vis[l][r][x][y]) return dp[l][r][x][y];
vis[l][r][x][y] = 1;
... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;
public class D {
public static void main(String[] args) {
Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(
System.in)));
int n = sc.nextInt();
... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
double dp[2010][2010][2][2], p;
int n, h;
int A[2010];
int Ai[2010];
int Bi[2010];
double f(int i, int j, int ok1, int ok2) {
if (i > j) return 0;
if (dp[i][j][ok1][ok2] != -1) {
return dp[i][j][ok1][ok2];
}
double ans = 0;
int p1 = min(Ai[i], j);
int p2 = m... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
const int N = 2 * 1e3 + 5;
int x[N];
double dp[N][N][2][2];
double vis[N][N][2][2];
int L[N], R[N];
double deal(int l, int r, int fl, int fr, double p, double h, int n) {
double ret = 0;
double ll = h, rr = h;
if (vis[l][r][fl][fr]) return dp[l][r][fl][fr];
if (l > ... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:667772160")
template <class T1>
void deb(T1 e1) {
cout << e1 << endl;
}
template <class T1, class T2>
void deb(T1 e1, T2 e2) {
cout << e1 << " " << e2 << endl;
}
template <class T1, class T2, class T3>
void deb(T1 e1, T2 e2, T3 e3) {
co... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
int N, H;
long double p, q;
long double dp[4][2005][2005];
int pos[2005];
double solve(int msk, int l, int r) {
if (l > r) {
return 0;
}
if (dp[msk][l][r] + 1) {
return dp[msk][l][r];
}
int cstll, cstlr, cstrl, cstrr;
dp[msk][l][r] = 0;
if (msk & 1) {
... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | //package round331;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.Random;
public class DS {
InputStream is;
PrintWriter out;
String INPUT = "";
void solve(... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
template <typename T>
void pr(vector<T> &v) {
for (int i = 0; i < (int)(v).size(); i++) cout << v[i] << " ";
cout << '\n';
;
}
template <typename T>
void pr(vector<vector<T>> &v) {
for (int i = 0; i < (int)(v).size(); i++) {
pr(v[i]);
}
}
template <typename T>... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | import java.util.*;
public class D331 {
static int[] xpos;
static int h;
static double p;
static double dp[][][];
static int[][] knockIndex;
public static void main(String[] args) {
Scanner qwe = new Scanner(System.in);
int n = qwe.nextInt();
xpos = new int[n];
h = qwe.nextInt();
p = qwe.nextDoub... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
const int maxN = 2005;
const int inf = 1e9;
double p_left;
double p_right;
int height, n, x[maxN];
int to_right[maxN], to_left[maxN];
double dp[maxN][maxN][2][2];
bool used[maxN][maxN][2][2];
int get_right(int pos, int est) {
int tmp = height;
if (pos < n - 1) {
int... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
int n, h;
int pl[2005], tut1[2005], tut2[2005], vis[2005][2005][2][2];
double p;
double dp[2005][2005][2][2];
double dfs(int bas, int son, int bef, int aft) {
double res = 0;
if (bas > son) return 0;
if (vis[bas][son][bef][aft]) return dp[bas][son][bef][aft];
if (be... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 2 * 1005;
const int inf = 1 << 28;
double pi = acos(-1.0);
int x[maxn];
int dl[maxn];
int dr[maxn];
double dp[maxn][maxn][2][2];
int vis[maxn][maxn][2][2];
int n, h;
double p;
double dfs(int L, int R, int f1, int f2) {
if (L > R) return 0;
if (vis[L][R]... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
int n, h;
double p;
int A[2010];
const int LEFT = 1;
const int RIGHT = 2;
const int NEITHER = 0;
double dp[2010][2010][2][2];
double solve(int s, int e, bool left_in, bool right_in) {
if (s > e) return 0.0;
double &ans = dp[s][e][left_in][right_in];
if (ans == ans) re... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
double P, dp[2005][2005][2][2];
int N, H, pos[2005], dl[2005], dr[2005];
double dfs(int l, int r, int f1, int f2) {
if (dp[l][r][f1][f2]) return dp[l][r][f1][f2];
if (l > r) return 0.0;
double& res = dp[l][r][f1][f2];
res +=
0.5 * P * (min... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 2005;
const int INF = (int)1e9;
int N, H;
long double P;
int x[MAXN];
int l[MAXN], r[MAXN];
long double dp[MAXN][MAXN][2][2];
long double rec(int lo, int hi, int i, int j) {
long double &ref = dp[lo][hi][i][j];
if (ref != -1) return ref;
if (lo > hi) ... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
double avg[2001][2001][2][2];
int next_right[2000];
int next_left[2000];
int pos[2000];
int n, h;
double p;
double getleft(int index, int fall_to_left) {
if (index == 0)
return h;
else if (!fall_to_left)
return min(pos[index] - pos[index - 1], h);
else
ret... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
deque<int> x;
bool vs[2002][2][2002][2];
double pd[2002][2][2002][2];
int nr[2002];
int nl[2002];
double p;
int h, n;
double solve(int l, bool lf, int r, bool rf) {
if (l > r) {
return 0;
}
double& ans = pd[l][lf][r][rf];
bool& vis = vs[l][lf][r][rf];
if (vis)... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | import java.util.*;
/**
* @auther chao
* @date 15/12/30
*/
public class MainApp {
static double[][][][] dp;
static int[] a;
static int[] R;
static int[] L;
static double p;
static int n;
static int h;
static final int LIMIT = 100000000;
public static void main(String[] args) {
... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 2010;
int v[MAXN];
int n, h;
double p;
double dp[MAXN][MAXN][2][2];
bool calc[MAXN][MAXN][2][2];
int rr[MAXN];
int lr[MAXN];
double solve(int l, int r, int tl, int tr) {
if (l > r) return 0;
if (calc[l][r][tl][tr]) return dp[l][r][tl][tr];
int freel =... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 2005;
double p;
int loc[MAXN], n, h, lt[MAXN], rt[MAXN];
long long sum[MAXN];
double dp[MAXN][MAXN][4];
int vis[MAXN][MAXN][4];
vector<int> comp;
int lb(int x) { return *lower_bound(comp.begin(), comp.end(), x); }
double go(int l, int r, int state) {
if (... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
double dp[2005][2005][2][2];
int pos[2005];
int ll[2005], rr[2005];
int n;
double p, h;
void ini() {
ll[1] = 1;
for (register int i = 2; i <= n; i++) {
if (pos[i] - pos[i - 1] < h)
ll[i] = ll[i - 1];
else
ll[i] = i;
}
rr[n] = n;
for (register i... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
const long long MaxN = 2050;
template <class t>
inline void read(t &s) {
s = 0;
register long long f = 1;
register char c = getchar();
while (!isdigit(c)) {
if (c == '-') f = -1;
c = getchar();
}
while (isdigit(c)) s = (s << 3) + (s << 1) + (c ^ 48), c = getchar();
s *= f;... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
vector<long long> vpos;
double memo[2005][2005][2][2];
int vis[2005][2005][2][2];
int n;
long long h;
double p;
int pretoright[2005];
int pretoleft[2005];
double pd(int l, int r, int f1, int f2) {
if (l > r) {
return 0.0;
} else if (vis[l][r][f1][f2]) {
return m... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
double p, h;
int n;
vector<double> vll;
double dp[2000 + 10][2000 + 10][2][2];
double lef[2000 + 10], rig[2000 + 10];
double dfs(int l, int r, int x, int y) {
int i, j, k;
double left_value, right_value;
double fall_left, fall_right, cover, bound;
if (l > r) return ... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const long long int maxn = 1e6 + 1;
double pie = 3.1415926535;
double dp[2002][2002][2][2], p;
long long int h, dright[2002], dleft[2002], a[2002];
double go(long long int lidx, long long int ridx, bool s, bool d,
long long int ls, long lo... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:36777216")
using namespace std;
const long double EPS = 1e-9;
const int INF = 1e9 + 7;
long double dp[4][2002][2002];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout << fixed << setprecision(7);
int n, h;... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
int x[2010];
double p;
int h;
double dp[2010][2010][2][2];
int main() {
int n, i, j, a, b;
scanf("%d", &n);
scanf("%d", &h);
scanf("%lf", &p);
for (i = 0; i < n; ++i) scanf("%d", &x[i]);
x[n] = -1000000000;
x[n + 1] = 1000000000;
sort(x, x + n + 2);
for (i... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
double p;
int n, h;
const int siz = 2000;
double memo[siz][siz][2][2];
int arr[siz];
int getL(int i) { return i <= 0 ? 1e9 : arr[i] - arr[i - 1]; }
int getR(int i) { return i >= n - 1 ? 1e9 : arr[i + 1] - arr[i]; }
double rec(int l, int r, int bl, int br) {
if (l > r || r... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
int N, H;
double P;
int place[2010] = {0};
double F[2010][2010][2][2] = {{{{0}}}};
double G[2010][2010][2][2] = {{{{0}}}};
int Left[2010] = {0};
int Right[2010] = {0};
int main() {
cin >> N >> H >> P;
for (int i = 1; i <= N; i++) scanf("%d", &place[i]);
sort(place + 1... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
int n, h;
double p;
int x[2020];
double dp[2020][2020][2][2];
bool vis[2020][2020][2][2];
int L[2020], R[2020];
double calc(double l, double r, double ll, double rr) {
l = max(l, ll);
r = min(r, rr);
if (l > r) return 0;
return r - l;
}
double f(int l, int r, int a,... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | import java.io.*;
import java.util.*;
public class R331qD {
/*
static int n,h;
static double p;
static int x[];
static int right[],left[];
static double dp[][][][];
*/
public static void main(String args[]) {
InputReader in = new InputReader(System.in);
PrintWriter w = new PrintWriter(System.out);
... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
double dp[2005][2005][2][2];
int vis[2005][2005][2][2];
int n;
double h, p;
int v[2005];
int dl[2005], dr[2005];
double dfs(int l, int r, int f1, int f2) {
if (vis[l][r][f1][f2]) return dp[l][r][f1][f2];
if (l > r) return 0;
vis[l][r][f1][f2] = 1;... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
const int N = 2050;
long double x[N], h, p, R[N], L[N], dp[N][N][2][2];
int n;
long double cnt(int l, int r, int xx, int yy) {
if (dp[l][r][xx][yy]) return dp[l][r][xx][yy];
if (l > r) return 0;
long double result = 0;
int newl = R[l];
int newr = L[r];
result +=... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
const int N = 2003;
double memo[N][N][2][2];
bool visi[N][N][2][2];
double p;
int lf[N], rf[N];
long long int x[N];
int n;
long long int h;
long long int calc(int i, bool side, bool occ) {
if (side == 1) {
if (i == n - 1)
return h;
else
return min(h, m... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
const int Maxn = 2020;
int n, h;
double p;
int x[Maxn], l[Maxn], r[Maxn];
double dp[Maxn][Maxn][2][2];
double dfs(int L, int R, int lrest, int rrest) {
double &t = dp[L][R][lrest][rrest];
if (t >= 0) return t;
t = 0;
if (L == R) {
double t1 = lrest ? min(x[L] - ... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
template <class T>
int getbit(T s, int i) {
return (s >> i) & 1;
}
template <class T>
T onbit(T s, int i) {
return s | (T(1) << i);
}
template <class T>
T offbit(T s, int i) {
return s & (~(T(1) << i));
}
template <class T>
int cntbit(T s) {
return __builtin_popcoun... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
double dp[2020][2020][2][2];
bool vis[2020][2020][2][2];
int n, h, x[2020];
int tor[2020], tol[2020];
double p;
double solve(int l, int r, int fl, int fr) {
if (vis[l][r][fl][fr]) return dp[l][r][fl][fr];
dp[l][r][fl][fr] = 0.0;
vis[l][r][fl][fr] = 1;
if (l == r) {
... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
const int N = 2005, INF = 0x3f3f3f3f;
const long double eps = 1e-9;
long double dp[2][2][N][N];
int n, h, x[N], tol[N], tor[N];
double p;
long double dfs(int lasl, int lasr, int L, int R) {
if (L > R) return 0.;
long double &ans = dp[lasl][lasr][L][R];
if (ans > -eps)... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 2015;
const int inf = 1 << 29;
int n, h, a[maxn], l[maxn], r[maxn];
double p, dp[maxn][maxn][2][2];
int main() {
cin >> n >> h >> p;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a, a + n);
for (int i = 0; i < n; i++) {
int lb = i - 1;... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
int n, h, x[2005], r[2005], l[2005];
double p, dp[2005][2005][2][2];
int main() {
scanf("%d %d %lf", &n, &h, &p);
for (int i = 1; i <= n; i++) {
scanf("%d", &x[i]);
}
sort(x + 1, x + 1 + n);
x[0] = -1e9, x[n + 1] = 1e9;
for (int i = 1; i <= n; i++) {
int... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
const int N = 2005;
const int INF = 0x3F3F3F3F;
int n, h, x[N], f[N], g[N];
double p, q, dp[N][N][2][2];
double calc(int l, int r, int ld, int rd) {
double &ans = dp[l][r][ld][rd];
if (l > r) return 0;
if (ans > 0) return ans;
int ll = (ld == 0) ? x[l - 1] : x[l - 1... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
int h, x[2005], l[2005], r[2005], n, i, xx;
double sc, p, q, DP[2005][2005][2][2];
double dp(int i, int j, int s, int d) {
if (i > j) return 0;
if (DP[i][j][s][d]) return DP[i][j][s][d];
int st, dr;
if (s == 0)
st = x[i - 1];
else
st = x[i - 1] + h;
if (... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
double ans, p, f[2011][2011][2][2], g[2011][2011][2][2];
int i, j, k, n, m, a[2011], b1[2011], b2[2011];
void work(int x, int y, int t1, int t2) {
double tmp = f[x][y][t1][t2], w = g[x][y][t1][t2];
if (x == y) {
ans +=
p * (tmp + w * min(t1 ? (a[x] - a[x - 1... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
bool solved[2003][2003][2][2];
int n, h, X[2003], R[2003], L[2003];
double p, M[2003][2003][2][2];
double DP(int l, int r, bool leftL, bool leftR) {
if (l > r) return 0;
if (solved[l][r][leftL][leftR]) return M[l][r][leftL][leftR];
solved[l][r][leftL][leftR] = true;
... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
const int inf = 1e8 + 5;
const int N = 2005;
int pos[N], h, n, L[N], R[N];
double p, dp[N][N][2][2];
int check(int op, int x, int dir) {
if (op == 0) {
if (!dir)
return min(pos[x] - pos[x - 1], h);
else
return min(h, max(pos[x] - pos[x - 1] - h, 0));
... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class C596D {
public static void main(String[] args) throws Exception {
new C596D().run();
out.close();
}
int bound(int x, int bound) {
... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
int n, h;
double p, q, hp, hq;
int _x[2002], l[2000], r[2000], *x = _x + 1;
double d[2][2][2000][2000] = {};
const double EPS = 1e-22;
int main() {
scanf("%d%d%lf", &n, &h, &p);
q = 1 - p, hp = 0.5 * p, hq = 0.5 * q;
for (int i = 0; i < (int)(n); ++i) scanf("%d", x + ... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
int n;
double h, p, point[2001];
pair<int, int> tree[2001][3];
void calc() {
for (int i = 0; i < n; i++) {
tree[i][0] = make_pair(0, 0);
tree[i][1] = make_pair(0, 0);
}
int prv1, prv2;
for (int i = 0; i < n; i++) {
prv1 = i;
prv2 = i;
for (int j ... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
long long int n, h;
double p;
long long int dizi[2004];
bool used[2004][2004][2][2];
double dp[2004][2004][2][2];
long double f(int x, int y, int a, int b) {
if (x > y) return 0;
if (used[x][y][a][b]) return dp[x][y][a][b];
used[x][y][a][b] = 1;
long long int sol = ... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const int mod = inf + 7;
const double eps = 1e-9;
const double pi = acos(-1.0);
double p, q;
int n, h, x[2020];
bool R[2020], L[2020];
int back[2020], front[2020];
bool calced[2][2][2020][2020];
double dp[2][2][2020][2020];
pair<int, int> get(int x... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
const int size = 2111;
const int mod = 1000000007;
double dp[size][size][2][2], p;
int n, h, x[size], le[size], ri[size];
double cal(int l, int r, int a, int b) {
if (r < l) return 0;
if (dp[l][r][a][b] != 0) return dp[l][r][a][b];
dp[l][r][a][b] = 0;
double tmp = 0... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
int n, h;
double p, answer = 0;
vector<int> x;
vector<int> LenFallToLeft, LenFallToRight;
vector<int> CntFallToLeft, CntFallToRight;
const int maxN = 2007;
double D[maxN][maxN][2][2];
void calc(int left, int right, int lout, int rout) {
double curP = D[left][right][lout][... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 2010;
double d[maxn][maxn][2][2];
bool vis[maxn][maxn][2][2];
int n, h, x[maxn], L[maxn], R[maxn];
double p;
double dp(int l, int r, int a, int b) {
double& ans = d[l][r][a][b];
if (vis[l][r][a][b]) return ans;
vis[l][r][a][b] = 1;
if (l > r) return... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
int x[2010];
int n, h;
double p;
double dp[2010][2010][2][2];
double f(int l, int r, int dl, int dr) {
if (l > r) return 0;
if (dp[l][r][dl][dr] != -1) return dp[l][r][dl][dr];
if (dl == 1 && x[l] - x[l - 1] < h) {
if (r > l || dr == 1)
return dp[l][r][dl][d... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
int x[2222];
int dr[2222];
int dl[2222];
bool was[2222][2222][2][2];
double dp[2222][2222][2][2];
int n, h;
double p, rp;
void calc() {
for (int i = 0; i <= n; ++i) {
int j = i;
while (j + 1 <= n && x[j] + h > x[j + 1]) j++;
dr[i] = j;
}
for (int i = n; i ... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 10;
const long long int INFLL = (long long int)1e18 + 10;
const long double EPS = 1e-8;
const long double EPSLD = 1e-18;
const long long int MOD = 1e9 + 7;
template <class T>
T &chmin(T &a, const T &b) {
return a = min(a, b);
}
template <class T>
T &... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
int n, h, arr[2010], sz[2][2010];
double dp[2010][2010][2][2], p;
double compute(int lef, int rig, int fl, int fr) {
if (lef > rig) return 0;
if (dp[lef][rig][fl][fr] != -1) return dp[lef][rig][fl][fr];
dp[lef][rig][fl][fr] = 0;
double ans = 0;
int nl = min(rig, l... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
double dp[2010][2010][2][2];
int pos[2010], vis[2010][2010][2][2], sz[2][2010], n, h;
double p;
double compute(int L, int R, int fl, int fr) {
if (L > R) return 0;
if (vis[L][R][fl][fr]) return dp[L][R][fl][fr];
vis[L][R][fl][fr] = 1;
double& ans = dp[L][R][fl][fr];... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const int MOD = 1e9 + 7;
const int N = 2e3 + 10;
int n, hei, fr[N], fl[N], a[N];
double pro, g[N][N][2][2];
void prepare() {
scanf("%d%d%lf", &n, &hei, &pro);
for (auto i = 1; i <= n; i++) scanf("%d", a + i);
sort(a + 1, a + n + 1);
a[n + 1] = i... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
int n;
int pos[2005], maxl[2005], maxr[2005];
double p, h;
double dp[2005][2005][2][2];
void pre() {
maxl[1] = 1;
for (int i = 2; i <= n; i++) {
if (pos[i] - pos[i - 1] < h)
maxl[i] = maxl[i - 1];
else
maxl[i] = i;
}
maxr[n] = n;
for (int i = n... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
int n, h;
double p, dp[2009][2009][2][2];
int a[2009], L[2009], R[2009];
bool vis[2009][2009][2][2];
double dfs(int l, int r, int x, int y) {
if (vis[l][r][x][y]) return dp[l][r][x][y];
vis[l][r][x][y] = 1;
double &ans = dp[l][r][x][y];
ans = 0;
int left, right;
... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
int n, h;
double p;
int A[2007], L[2007], R[2007];
double dp[2007][2007][2][2];
bool flag[2007][2007][2][2] = {0};
double f(int l, int r, int a, int b) {
if (l > r) return 0;
if (flag[l][r][a][b]) return dp[l][r][a][b];
double l0 = 0;
if (a == 1)
l0 = min(h, A[l... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
const int N = 2005;
int n, h;
double p;
int a[N], f[N], b[N];
double dp[N][N][2][2];
double f1(int l, int r, int d1, int d2) {
if (l > r) return 0;
if (dp[l][r][d1][d2] != -1) return dp[l][r][d1][d2];
double &res = dp[l][r][d1][d2];
res = 0;
if (d1 == -1)
res ... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
const int N = 2002;
int n, h, inf = 1e9;
int x[N], l[N], r[N];
long double dp[N][N][2][2], p;
long double go(int i, int j, int s, int t) {
if (i > j) return 0;
long double &ans = dp[i][j][s][t];
if (ans > 0) return ans;
int lft = (s == 0) ? x[i - 1] : x[i - 1] + h;
... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
int pos[2010];
double dp[2010][2010][2][2];
bool flag[2010][2010][2][2];
double getProb(int st, int h, double p, int l, int r) {
int lft = pos[st - 1], rt = pos[st + 1];
if (l == 1) lft += h;
if (r == 1) rt -= h;
return p * min(h, abs(pos[st] - lft)) + (1 - p) * min... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 2010;
int N, h, pos[MAXN], rm[MAXN], lm[MAXN];
double p, dn[MAXN][MAXN][2][2];
double f(int b, int e, bool l, bool r) {
if (b > e) return 0.;
double &ret = dn[b][e][l][r];
if (ret != -1.) return ret;
double res = 0.;
res += 0.5 * p *
(f(b... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
void SR(int &x) { scanf("%d", &x); }
void SR(long long &x) { scanf("%lld", &x); }
void SR(double &x) { scanf("%lf", &x); }
void SR(char *s) { scanf("%s", s); }
void RI() {}
template <typename I, typename... T>
void RI(I &x, T &...tail) {
SR(x);
RI(tail...);
}
void SP(co... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
double pos[2005];
double dp[2005][2005][2][2];
int pre[2005][2];
int n;
double p, h;
void precompute() {
pre[n][1] = n + 1;
for (int i = n - 1; i >= 1; i--) {
if (pos[i] + h > pos[i + 1])
pre[i][1] = pre[i + 1][1];
else
pre[i][1] = i + 1;
}
pre[1... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
int n, h, A[2005];
double p, dp[2][2][2005][2005];
double dfs(int x, int y, int l, int r) {
if (l > r) return 0;
double &T = dp[x][y][l][r];
if (T != -1)
return T;
else if (x == 1 && A[l] - A[l - 1] < h)
T = dfs(1, y, l + 1, r) + min(h, A[l + 1] - A[l] - (l ... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
double dp[2005][2005][4], p;
int n, x[2005], h;
int nxtl[2005], nxtr[2005];
double dfs(int l, int r, int op) {
if (l > r) return 0;
if (dp[l][r][op]) return dp[l][r][op];
dp[l][r][op] +=
0.5 * p *
(min(x[l] - x[l - 1] - h * (op & 1), h) + dfs(l + 1, r, op ... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
int n, h;
double p;
double memexpected[2001][2001][2][2];
int calculado[2001][2001][2][2];
int ri[2001], le[2001];
int v[2001];
double expected(int i1, int i2, int l1, int l2) {
if (i1 > i2) return 0;
double &mem = memexpected[i1][i2][l1][l2];
if (calculado[i1][i2][l1... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 2005;
const int INFTY = 1 << 30;
int N, H;
double P;
int pos[MAXN];
int L[MAXN], R[MAXN];
double dp[MAXN][MAXN][2][2];
double getdp(int left, int right, int a, int b) {
if (left > right) return 0;
if (dp[left][right][a][b] != -1) return dp[left][right][... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
template <class P, class Q>
inline P smax(P &a, Q b) {
if (a < b) a = b;
return a;
}
template <class P, class Q>
inline P smin(P &a, Q b) {
if (b < a) a = b;
return a;
}
const long long maxN = 2049;
const long long oo = 1e9 + 4 + 9;
const long long mod = 0;
const lo... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
int n, h;
double p;
int a[3000];
double d[2005][2005][2][2];
int dat[3000][2];
int main() {
int i, j, k, l;
cin >> n >> h >> p;
for (i = 0; i < n; i++) scanf("%d", &a[i]);
a[n] = -((1 << 30) - 1), a[n + 1] = ((1 << 30) - 1);
sort(a,... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
template <class T>
T abs(T x) {
return x > 0 ? x : -x;
}
int m;
int n;
double p;
int h;
int x[2500];
double table[2100][2100][2][2];
int was[2100][2100][2][2];
int nextl[2100];
int nextr[2100];
double getans(int l, int r, int f1, int f2) {
if (l > r) return 0;
double ... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
const int N = 2100;
long double p;
int n;
int a[N], h;
int A[N], B[N];
long double dp[N][N][2][2];
long double solve(int lft, int rht, int l, int r) {
if (dp[lft][rht][l][r] >= 0) return dp[lft][rht][l][r];
long double res = 0.0;
if (lft == rht) {
if (!l)
re... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
int read() {
int kkk = 0, x = 1;
char c = getchar();
while ((c < '0' || c > '9') && c != '-') c = getchar();
if (c == '-') c = getchar(), x = -1;
while (c >= '0' && c <= '9') kkk = kkk * 10 + (c - '0'), c = getchar();
return kkk * x;
}
int n, h, x[2010], L[2010]... |
Problem: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.
There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.
The trees are equal, i.e. each tree has ... | #include <bits/stdc++.h>
using namespace std;
int n, h, arr[2010], sz[2][2010];
double dp[2010][2010][2][2], p;
double compute(int lef, int rig, int fl, int fr) {
if (lef > rig) return 0;
if (dp[lef][rig][fl][fr] != -1) return dp[lef][rig][fl][fr];
dp[lef][rig][fl][fr] = 0;
double ans = 0;
int nl = min(rig, l... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.