Submission #5524572
Source Code Expand
// warm heart, wagging tail,and a smile just for you! // ███████████ // ███╬╬╬╬╬╬╬╬╬╬███ // ███╬╬╬╬╬████╬╬╬╬╬╬███ // ███████████ ██╬╬╬╬╬████╬╬████╬╬╬╬╬██ // █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██ // ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██ // ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██ // ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████ // ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██ // ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███ // ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██ // ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████ // █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████ // ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██ // ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██ // ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███ // ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████ // ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████ // ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██ // ██████████████ ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████ // ███████ █████ ███████████████████ #include "bits/stdc++.h" using namespace std; #define MOD 1000000007 //#define MOD 998244353 const double EPS = 1e-9; #define INF (1LL<<60) #define D double #define fs first #define sc second #define int long long #define FOR(i,a,b) for(int i=(a);i<(b);i++) #define RFOR(i,a,b) for(int i = (b-1);i>=(a);i--) #define REP(i,n) FOR(i,0,(n)) #define RREP(i,n) RFOR(i,0,(n)) #define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr) #define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr) #define range(i,a,b) ((a)<=(i) && (i)<(b)) #define debug(x) cout << #x << " = " << (x) << endl; #define SP << " " << typedef pair<int,int> P; typedef vector<vector<P> > Graph; #include <cstdint> template <std::uint_fast64_t Modulus> class modint { using u64 = std::uint_fast64_t; u64 a; public: constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {} constexpr u64 value() const noexcept { return a; } constexpr modint operator+(const modint rhs) const noexcept { return modint(*this) += rhs; } constexpr modint operator-(const modint rhs) const noexcept { return modint(*this) -= rhs; } constexpr modint operator*(const modint rhs) const noexcept { return modint(*this) *= rhs; } constexpr modint operator/(const modint rhs) const noexcept { return modint(*this) /= rhs; } constexpr bool operator==(const modint rhs) const noexcept { return modint(*this).value() == rhs.value(); } modint &operator+=(const modint rhs) noexcept { a += rhs.a; if (a >= Modulus) { a -= Modulus; } return *this; } modint &operator-=(const modint rhs) noexcept { if (a < rhs.a) { a += Modulus; } a -= rhs.a; return *this; } modint &operator*=(const modint rhs) noexcept { a = a * rhs.a % Modulus; return *this; } modint &operator/=(modint rhs) noexcept { u64 exp = Modulus - 2; while (exp) { if (exp % 2) { *this *= rhs; } rhs *= rhs; exp /= 2; } return *this; } }; using mint = modint<MOD>; template <typename T> struct SegmentTree{ using F = function<T(T,T)>; int n; F f; T ti; vector<T> dat; SegmentTree(){}; SegmentTree(F f,T ti):f(f),ti(ti){} void init(int n_){ n=1; while(n<n_) n<<=1; dat.assign(n<<1,ti); } void build(const vector<T> &v){ int n_=v.size(); init(n_); for(int i=0;i<n_;i++) dat[n+i]=v[i]; for(int i=n-1;i;i--) dat[i]=f(dat[(i<<1)|0],dat[(i<<1)|1]); } void update(int k,T x){ dat[k+=n]=x; while(k>>=1) dat[k]=f(dat[(k<<1)|0],dat[(k<<1)|1]); } void add(int k,T x){ dat[k+=n]+=x; while(k>>=1) dat[k]=f(dat[(k<<1)|0],dat[(k<<1)|1]); } T query(int a,int b){ T vl=ti,vr=ti; for(int l=a+n,r=b+n;l<r;l>>=1,r>>=1) { if(l&1) vl=f(vl,dat[l++]); if(r&1) vr=f(dat[--r],vr); } return f(vl,vr); } }; typedef vector<mint> vec; typedef vector<vector<mint>> mat; signed main(){ ios::sync_with_stdio(false); cin.tie(0); int n,x,y; cin >> n >> x >> y; vector<int> a(n+1,-INF); REP(i,n) cin >> a[i+1]; if(x > y) swap(x,y); REP(i,n-1){ if(a[i+2] - a[i] < x){ cout << 0 << endl; return 0; } } auto f = [](mint a, mint b){return a+b;}; SegmentTree<mint> seg(f,0); vec tmp(n+1,0); tmp[0] = 1; seg.build(tmp); int id = 0; FOR(i,1,n+1){ int ub = upper_bound(a.begin(),a.end(),a[i]-y) - a.begin(); seg.update(i,seg.query(id,ub)); if(a[i]-a[i-1] < x) id = i-1; } cout << seg.query(id,n+1).value() << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Division into Two |
User | cinnamoroll |
Language | C++14 (GCC 5.4.1) |
Score | 1100 |
Code Size | 8574 Byte |
Status | AC |
Exec Time | 36 ms |
Memory | 3840 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 1100 / 1100 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | s1.txt, s2.txt, s3.txt, s4.txt |
All | 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, s1.txt, s2.txt, s3.txt, s4.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | AC | 32 ms | 3840 KB |
02.txt | AC | 32 ms | 3840 KB |
03.txt | AC | 31 ms | 3840 KB |
04.txt | AC | 30 ms | 3840 KB |
05.txt | AC | 35 ms | 3840 KB |
06.txt | AC | 30 ms | 3840 KB |
07.txt | AC | 31 ms | 3840 KB |
08.txt | AC | 31 ms | 3840 KB |
09.txt | AC | 30 ms | 3840 KB |
10.txt | AC | 31 ms | 3840 KB |
11.txt | AC | 30 ms | 3840 KB |
12.txt | AC | 36 ms | 3840 KB |
13.txt | AC | 34 ms | 3840 KB |
14.txt | AC | 30 ms | 3840 KB |
15.txt | AC | 30 ms | 3840 KB |
16.txt | AC | 21 ms | 3840 KB |
17.txt | AC | 23 ms | 3840 KB |
18.txt | AC | 24 ms | 3840 KB |
19.txt | AC | 27 ms | 3840 KB |
20.txt | AC | 26 ms | 3840 KB |
21.txt | AC | 26 ms | 3840 KB |
22.txt | AC | 26 ms | 3840 KB |
23.txt | AC | 26 ms | 3840 KB |
24.txt | AC | 25 ms | 3840 KB |
25.txt | AC | 29 ms | 3840 KB |
26.txt | AC | 28 ms | 3840 KB |
27.txt | AC | 28 ms | 3840 KB |
28.txt | AC | 28 ms | 3840 KB |
29.txt | AC | 27 ms | 3840 KB |
30.txt | AC | 27 ms | 3840 KB |
31.txt | AC | 27 ms | 3840 KB |
32.txt | AC | 28 ms | 3840 KB |
33.txt | AC | 29 ms | 3840 KB |
34.txt | AC | 26 ms | 3840 KB |
35.txt | AC | 29 ms | 3840 KB |
36.txt | AC | 29 ms | 3840 KB |
37.txt | AC | 29 ms | 3840 KB |
38.txt | AC | 28 ms | 3840 KB |
39.txt | AC | 36 ms | 3840 KB |
40.txt | AC | 24 ms | 3840 KB |
41.txt | AC | 25 ms | 3840 KB |
42.txt | AC | 11 ms | 1024 KB |
43.txt | AC | 36 ms | 3840 KB |
44.txt | AC | 36 ms | 3840 KB |
45.txt | AC | 36 ms | 3840 KB |
46.txt | AC | 36 ms | 3840 KB |
47.txt | AC | 16 ms | 1024 KB |
48.txt | AC | 16 ms | 1024 KB |
49.txt | AC | 1 ms | 256 KB |
50.txt | AC | 1 ms | 256 KB |
51.txt | AC | 1 ms | 256 KB |
52.txt | AC | 1 ms | 256 KB |
53.txt | AC | 1 ms | 256 KB |
54.txt | AC | 1 ms | 256 KB |
55.txt | AC | 1 ms | 256 KB |
56.txt | AC | 1 ms | 256 KB |
57.txt | AC | 1 ms | 256 KB |
58.txt | AC | 1 ms | 256 KB |
59.txt | AC | 1 ms | 256 KB |
60.txt | AC | 1 ms | 256 KB |
61.txt | AC | 1 ms | 256 KB |
62.txt | AC | 1 ms | 256 KB |
63.txt | AC | 1 ms | 256 KB |
64.txt | AC | 1 ms | 256 KB |
s1.txt | AC | 1 ms | 256 KB |
s2.txt | AC | 1 ms | 256 KB |
s3.txt | AC | 1 ms | 256 KB |
s4.txt | AC | 1 ms | 256 KB |