Submission #1072746

# Submission time Handle Problem Language Result Execution time Memory
1072746 2024-08-24T03:57:22 Z kunzaZa183 Fibonacci representations (CEOI18_fib) C++17
5 / 100
4000 ms 432 KB
#include <bits/stdc++.h>
using namespace std;

void add(set<int> &si, int x) {
  queue<int> qi;
  qi.push(x);
  while(!qi.empty()) {
    int tmp = qi.front();
    qi.pop();
    if(si.count(tmp)) {
      si.erase(tmp);
      if(tmp==1) {
        qi.push(2);
      } else if(tmp==2) {
        qi.push(1);
        qi.push(3);
      } else {
        qi.push(tmp-2);
        qi.push(tmp + 1);
      }
      continue;
    } else if(si.count(tmp + 1)) {
      si.erase(tmp + 1);
      qi.push(tmp + 2);
    } else if(si.count(tmp - 1)) {
      si.erase(tmp - 1);
      qi.push(tmp + 1);
    } else {
      si.insert(tmp);
    }
  }
}

const int mod = 1e9+7;
int state(set<int> vi, int cur) {
  if(vi.empty())
    return 1;
  int x = *vi.rbegin();
  if(cur==1) {
    if(vi.size() > 1)
      return 0;
    if(x==1)
      return 1;
  }

  int total = 0;
  vi.erase(x);
  if( x <=cur) {
    total += state(vi,x - 1);
  }
  if(x - 1<=cur && x>2)
  {
    add(vi, x - 2);
    total += state(vi,x - 2);
  }
  return total % mod;
}

int main() {
  int n;
  cin>>n;
  vector<int> vi(n);
  
  for(auto &a:vi)
    cin>>a;
  
  set<int> cur;
  for(auto a:vi) {
    add(cur,a);
    cout<<state(cur, 100)<<"\n";
  }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 432 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 432 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 344 KB Output is correct
8 Execution timed out 4097 ms 424 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 432 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 344 KB Output is correct
8 Execution timed out 4097 ms 424 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 432 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 344 KB Output is correct
8 Execution timed out 4097 ms 424 KB Time limit exceeded
9 Halted 0 ms 0 KB -