# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
287555 | 2020-08-31T20:01:53 Z | TadijaSebez | Fibonacci representations (CEOI18_fib) | C++11 | 1 ms | 384 KB |
#include <bits/stdc++.h> using namespace std; #define ll long long const int mod=1e9+7; int add(int x,int y){x+=y;return x>=mod?x-mod:x;} int mul(int x,int y){return (ll)x*y%mod;} const int N=150; int cnt[N]; void Fix(){ while(1){ bool ok=0; if(cnt[1]==2)cnt[1]=0,cnt[2]++,ok=1; for(int i=2;i<N;i++){ assert(cnt[i]<3); if(cnt[i]&&cnt[i-1]){ cnt[i-1]--; cnt[i]--; cnt[i+1]++; ok=1; } if(cnt[i]==2){ cnt[i]-=2; cnt[i-2]++; cnt[i+1]++; ok=1; } } if(!ok)break; } } int Solve(){ int dp[2]={1,0},las=0; for(int i=1;i<N;i++)if(cnt[i]){ int d0=add(dp[0],dp[1]); int sz=i-las-1; int d1=add(mul(dp[0],sz/2),mul(dp[1],(sz+1)/2)); las=i;dp[0]=d0;dp[1]=d1; } return add(dp[0],dp[1]); } int main(){ int n; scanf("%i",&n); for(int i=1;i<=n;i++){ int a; scanf("%i",&a); cnt[a]++; Fix(); printf("%i\n",Solve()); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 0 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 0 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 384 KB | Output is correct |
7 | Incorrect | 0 ms | 256 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 288 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 0 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 384 KB | Output is correct |
7 | Incorrect | 0 ms | 256 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 384 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 0 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 384 KB | Output is correct |
7 | Incorrect | 0 ms | 256 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |