제출 #1126522

#제출 시각아이디문제언어결과실행 시간메모리
1126522wjankowskiFibonacci representations (CEOI18_fib)C++20
0 / 100
1 ms324 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long constexpr int mod = 1e9+7; set <int> s; void add(int a) { if(a == -1) return; if(a == 0) a++; if(s.count(a+1)) s.erase(a+1), add(a+2); else if(s.count(a-1)) s.erase(a-1), add(a+1); else if(s.count(a)) s.erase(a), add(a-2), add(a+1); else s.insert(a); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; for(int i=1,a; i<=n; i++) { cin >> a; add(a); int ls = 0; ll dp[2]; dp[0] = 1, dp[1] = 0; for(auto x : s) { ll v0 = (dp[0]+dp[1])%mod; ll v1 = ((dp[0]*(x-ls-1)/2)%mod+(dp[1]*(x-ls)/2)%mod)%mod; dp[0] = v0, dp[1] = v1; ls = x; } cout << (dp[0]+dp[1])%mod << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...