# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
71713 | the_general (#119) | Cross on the Grid (FXCUP3_cross) | C++98 | 4 ms | 580 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<stdio.h>
#define MOD 1000000007
int a(int);
int b(int);
int c(int);
int d(int);
int n;
int A[4];
int B[4];
int C[4];
int D[4];
int a(int x){
if(x<3) return 0;
if(x==3) return 1;
return (((C[1]+D[0]-B[0])%MOD+B[1])%MOD+D[0])%MOD;
}
int b(int x){
if(x<3) return 0;
if(x==3) return 1;
return (((C[1]+D[0]-A[0])%MOD+A[1])%MOD+D[0])%MOD;
}
int c(int x){
if(x<3) return 0;
if(x==3) return 1;
return ((A[1]+B[1])%MOD+D[0])%MOD;
}
int d(int x){
if(x==1 || x==2){
D[3]=1;
for(int i=0;i<3;i++){
D[i]=D[i+1];
}
return 1;
}
A[3]=a(x);
B[3]=b(x);
C[3]=c(x);
D[3]=(((A[3]+B[3])%MOD+C[3])%MOD+D[2])%MOD;
for(int i=0;i<3;i++){
A[i]=A[i+1];
B[i]=B[i+1];
C[i]=C[i+1];
D[i]=D[i+1];
}
return D[3];
}
int main(){
scanf("%d", &n);
for(int i=1;i<=n;i++){
d(i);
}
printf("%d", D[3]);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |