# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
71772 | 2018-08-25T15:10:37 Z | tamref_official_fanclub(#2249, imeimi2000) | 십자가 놓기 (FXCUP3_cross) | C++17 | 5 ms | 656 KB |
#include <stdio.h> const int mod=1e9+7;struct mat{int x[16][16];mat operator*(const mat&p)const{mat ret;for(int i=0;i<16;++i){for(int j=0;j<16;++j){ret.x[i][j]=0;for(int k = 0;k<16;++k){ret.x[i][j]+=(long long)x[i][k]*p.x[k][j]%mod;ret.x[i][j]%=mod;}}}return ret;}}it;const int gox[5]={0,1,0,-1,0};const int goy[5]={0,0,1,0,-1};int collapse(int a,int b,int y){if(a==0||b==0)return 0;for(int i=0;i<5;++i){for(int j=0;j<5;++j){if(a+gox[i]!=b+gox[j])continue;if(goy[i]!=y+goy[j])continue;return 1;}}return 0;}mat pw(mat x,int p){mat ret=it;while(p){if(p&1)ret=ret*x;x=x*x;p>>=1;}return ret;}int main(){int n;scanf("%d",&n);mat x;for(int i=0;i<16;++i){for(int j=0;j<16;++j){x.x[i][j]=0;if((i>>2)==(j&3)){if(collapse(j>>2,i&3,2))continue;if(collapse(j&3,i&3,1))continue;x.x[i][j]=1;}}}for(int i=0;i<16;++i)it.x[i][i]=1;x=pw(x,n-3);int ans=0;for(int i=0;i<16;++i)for(int j=0;j<4;++j)ans=(ans+x.x[i][j])%mod;printf("%d\n",ans);return 0;}
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 356 KB | Output is correct |
3 | Correct | 2 ms | 356 KB | Output is correct |
4 | Correct | 3 ms | 448 KB | Output is correct |
5 | Correct | 2 ms | 508 KB | Output is correct |
6 | Correct | 2 ms | 508 KB | Output is correct |
7 | Correct | 2 ms | 508 KB | Output is correct |
8 | Correct | 3 ms | 592 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 356 KB | Output is correct |
3 | Correct | 2 ms | 356 KB | Output is correct |
4 | Correct | 3 ms | 448 KB | Output is correct |
5 | Correct | 2 ms | 508 KB | Output is correct |
6 | Correct | 2 ms | 508 KB | Output is correct |
7 | Correct | 2 ms | 508 KB | Output is correct |
8 | Correct | 3 ms | 592 KB | Output is correct |
9 | Correct | 2 ms | 592 KB | Output is correct |
10 | Correct | 3 ms | 592 KB | Output is correct |
11 | Correct | 3 ms | 592 KB | Output is correct |
12 | Correct | 3 ms | 592 KB | Output is correct |
13 | Correct | 3 ms | 596 KB | Output is correct |
14 | Correct | 3 ms | 596 KB | Output is correct |
15 | Correct | 3 ms | 656 KB | Output is correct |
16 | Correct | 4 ms | 656 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 356 KB | Output is correct |
3 | Correct | 2 ms | 356 KB | Output is correct |
4 | Correct | 3 ms | 448 KB | Output is correct |
5 | Correct | 2 ms | 508 KB | Output is correct |
6 | Correct | 2 ms | 508 KB | Output is correct |
7 | Correct | 2 ms | 508 KB | Output is correct |
8 | Correct | 3 ms | 592 KB | Output is correct |
9 | Correct | 2 ms | 592 KB | Output is correct |
10 | Correct | 3 ms | 592 KB | Output is correct |
11 | Correct | 3 ms | 592 KB | Output is correct |
12 | Correct | 3 ms | 592 KB | Output is correct |
13 | Correct | 3 ms | 596 KB | Output is correct |
14 | Correct | 3 ms | 596 KB | Output is correct |
15 | Correct | 3 ms | 656 KB | Output is correct |
16 | Correct | 4 ms | 656 KB | Output is correct |
17 | Correct | 4 ms | 656 KB | Output is correct |
18 | Correct | 4 ms | 656 KB | Output is correct |
19 | Correct | 3 ms | 656 KB | Output is correct |
20 | Correct | 4 ms | 656 KB | Output is correct |
21 | Correct | 3 ms | 656 KB | Output is correct |
22 | Correct | 3 ms | 656 KB | Output is correct |
23 | Correct | 5 ms | 656 KB | Output is correct |
24 | Correct | 4 ms | 656 KB | Output is correct |
25 | Correct | 4 ms | 656 KB | Output is correct |