# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
133871 | 2019-07-21T15:51:53 Z | sebinkim | Fibonacci representations (CEOI18_fib) | C++14 | 4000 ms | 2048 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair <ll, ll> pll; const ll mod = 1e9 + 7; set <pll> S; ll n; void erase(set <pll>::iterator it) { S.erase(it); } void insert(pll p) { S.insert(p); } void insert(ll t, ll x) { auto it = S.lower_bound(pll(x, 1e9)); if(it == S.begin() || prev(it) -> second < x){ pll p(x - 1, x + 1); if(it != S.begin() && prev(it) -> second + 1 == x){ p.first = prev(it) -> first; erase(prev(it)); } it = S.lower_bound(pll(x, 1e9)); if(it != S.end() && x + 1 == it -> first){ p.second = it -> second; erase(it); } insert(p); } else{ it = prev(it); if(it -> second - x & 1){ pll p(it -> first, x - 1); ll x1 = it -> first - 1, x2 = it -> second; erase(it); insert(t, x2); if(p.first < p.second) insert(p); if(x1 > 0) insert(t, x1); } else{ pll p(it -> first, it -> second == x? x - 2: x); x = it -> second + 1; erase(it); insert(t, x); if(p.first < p.second) insert(p); } } } int main() { ll i, x; ll d0, d1, lt, _d0, _d1, l; scanf("%lld", &n); for(i=0; i<n; i++){ scanf("%lld", &x); insert(i, x); d0 = 0; d1 = 1; lt = 0; for(pll t: S){ l = t.first + 1 - lt; _d0 = ((l / 2) * d0 + (l - 1) / 2 * d1) % mod; _d1 = d1 + d0; d0 = _d0; d1 = _d1; lt = t.second - 1; } printf("%lld\n", (d0 + d1) % mod); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 504 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 504 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 504 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Execution timed out | 4003 ms | 2048 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 504 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |