Submission #2099720


Source Code Expand

#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, V;
int M, SM;

int T[21][MAX_N];
int nex[21][MAX_N];

int dp[(1 << 22)], rdp[(1 << 22)];
int ok[MAX_N];

vector<ll> v;
ll A[MAX_N];

void pre(int dp[MAX_N]) {
	rep(i, 0, M) {
		rep(j, 0, N - 1) {
			T[0][j] = (abs(A[j + 1] - A[j]) > v[i]) ? j : (j + 1);
		}
		T[0][N - 1] = N - 1;
		rep(q, 0, 20) {
			rep(j, 0, N) {
				T[q + 1][j] = T[q][T[q][j]];
			}
		}
		rep(j, 0, N) {
			nex[i][j] = T[20][j];
		}
	}
	rep(bit, 0, (1 << SM)) {
		if(dp[bit] == N - 1) continue;
		rep(i, 0, N) {
			if(bit & (1 << i)) continue;
			MAX(dp[bit | (1 << i)], nex[i][dp[bit] + 1]);
		}
	}
	rep(bit, 0, (1 << SM)) {
		if(dp[bit] == N - 1) continue;
		dp[bit] = nex[SM][dp[bit] + 1];
	}
}

void solve() {
	cin >> N >> V;
	rep(i, 0, N) cin >> A[i];
	while(V >= 1) {
		v.pb(V);
		V /= 2;
	}
	v.pb(0);
	M = sz(v);
	SM = M - 1;

	reverse(all(v));
	
	pre(dp);

	reverse(A, A + N);
	pre(rdp);

	rep(bit, 0, (1 << SM)) rdp[bit] = N - 1 - rdp[bit];

	rep(bit, 0, (1 << SM)) {
		int rbit = (1 << SM) - 1 - bit;
		int l = dp[bit], r = rdp[rbit];
		l++;
		if(l > r) {
			ok[l]--;
			ok[r]++;
		}
	}
	rep(i, 0, N) {
		ok[i + 1] += ok[i];
		if(ok[i]) cout << "Possible\n";
		else cout << "Impossible\n";
	}
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}

Submission Info

Submission Time
Task E - Camel and Oases
User omochana2
Language C++14 (GCC 5.4.1)
Score 0
Code Size 3169 Byte
Status RE
Exec Time 209 ms
Memory 43136 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 1000
Status
AC × 3
AC × 5
RE × 65
Set Name Test Cases
Sample 00_example_01.txt, 00_example_02.txt, 00_example_03.txt
All 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt, 40.txt, 41.txt, 42.txt, 43.txt, 44.txt, 45.txt, 46.txt, 47.txt, 48.txt, 49.txt, 50.txt, 51.txt, 52.txt, 53.txt, 54.txt, 55.txt, 56.txt, 57.txt, 58.txt, 59.txt, 60.txt, 61.txt, 62.txt, 63.txt, 64.txt, 65.txt, 66.txt, 67.txt
Case Name Status Exec Time Memory
00_example_01.txt AC 6 ms 22784 KB
00_example_02.txt AC 6 ms 22784 KB
00_example_03.txt AC 6 ms 26880 KB
01.txt RE 108 ms 41216 KB
02.txt RE 105 ms 39168 KB
03.txt RE 106 ms 41216 KB
04.txt RE 104 ms 39168 KB
05.txt RE 105 ms 41216 KB
06.txt RE 121 ms 41472 KB
07.txt RE 115 ms 39296 KB
08.txt RE 115 ms 41344 KB
09.txt RE 114 ms 39296 KB
10.txt RE 110 ms 41344 KB
11.txt RE 116 ms 39424 KB
12.txt RE 113 ms 41344 KB
13.txt RE 208 ms 43136 KB
14.txt RE 105 ms 41216 KB
15.txt RE 105 ms 39168 KB
16.txt RE 105 ms 41216 KB
17.txt RE 105 ms 39168 KB
18.txt RE 105 ms 41216 KB
19.txt RE 105 ms 39168 KB
20.txt RE 118 ms 41472 KB
21.txt RE 116 ms 39296 KB
22.txt RE 117 ms 41344 KB
23.txt RE 117 ms 39424 KB
24.txt RE 112 ms 41344 KB
25.txt RE 115 ms 39296 KB
26.txt RE 117 ms 41344 KB
27.txt RE 208 ms 43136 KB
28.txt RE 118 ms 41472 KB
29.txt RE 112 ms 39296 KB
30.txt RE 118 ms 41472 KB
31.txt RE 113 ms 39296 KB
32.txt RE 111 ms 41344 KB
33.txt RE 114 ms 39296 KB
34.txt RE 114 ms 41344 KB
35.txt RE 209 ms 43136 KB
36.txt RE 105 ms 41216 KB
37.txt RE 105 ms 39168 KB
38.txt RE 106 ms 41216 KB
39.txt RE 105 ms 39168 KB
40.txt RE 105 ms 41216 KB
41.txt RE 105 ms 39168 KB
42.txt RE 105 ms 41216 KB
43.txt RE 106 ms 39168 KB
44.txt RE 106 ms 41216 KB
45.txt RE 106 ms 39168 KB
46.txt RE 114 ms 39296 KB
47.txt RE 114 ms 41344 KB
48.txt RE 113 ms 39296 KB
49.txt RE 114 ms 41344 KB
50.txt RE 111 ms 39296 KB
51.txt RE 112 ms 41344 KB
52.txt RE 113 ms 39296 KB
53.txt RE 113 ms 41344 KB
54.txt RE 112 ms 39296 KB
55.txt RE 114 ms 41344 KB
56.txt RE 110 ms 39296 KB
57.txt RE 114 ms 41344 KB
58.txt RE 113 ms 39296 KB
59.txt RE 111 ms 41344 KB
60.txt RE 114 ms 39296 KB
61.txt RE 113 ms 41344 KB
62.txt RE 115 ms 39296 KB
63.txt RE 117 ms 41344 KB
64.txt RE 113 ms 39296 KB
65.txt RE 114 ms 41344 KB
66.txt AC 6 ms 22784 KB
67.txt AC 6 ms 22784 KB