답안 #972440

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
972440 2024-04-30T12:28:59 Z Charizard2021 Fibonacci representations (CEOI18_fib) C++17
5 / 100
1 ms 436 KB
#include<bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
map<int, int> mp;
void getValues(int x){
    if(mp[x] != 0){
        if(mp[x] == 1){
            if(x >= 1 && mp[x - 1] != 0){
                mp[x - 1]--;
                mp[x]--;
                mp[x + 1]++;
                getValues(x + 1);
            }
            else if(mp[x + 1] != 0) {
                mp[x]--;
                mp[x + 1]--;
                mp[x + 2]++;
                getValues(x + 2);
            }
        }
        else{
            mp[x] = 0;
            mp[x + 1]++;
            getValues(x + 1);
            if(x > 1){
                mp[x - 2]++;
                getValues(x - 2);
            }
            else if(x == 1){
                mp[0]++;
                getValues(0);
            }
        }
    }
}
int main(){
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        x--;
        mp[x]++;
        getValues(x);
        vector<int> a;
        for(auto it : mp){
            if(it.second != 0){
                a.push_back(it.first);
            }
        }
        vector<long long> dp((int)a.size());
        dp[0] = a[0]/2;
        int ans = 1;
        for(int j = 1; j < (int)a.size(); j++){
            dp[j] = ((a[j] - a[j - 1])/2 * dp[j - 1] + (a[j] - a[j - 1] - 1)/2 * ans) % MOD;
            ans += dp[j - 1];
            ans %= MOD;
        }
        cout << ans + dp.back() << "\n";
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Incorrect 1 ms 436 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Incorrect 1 ms 436 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Incorrect 1 ms 436 KB Output isn't correct
9 Halted 0 ms 0 KB -