Submission #62614

# Submission time Handle Problem Language Result Execution time Memory
62614 2018-07-29T11:03:46 Z 검수컵(#1978, imsifile) Cross on the Grid (FXCUP3_cross) C++
100 / 100
3 ms 604 KB
#include<stdio.h>
#include<memory.h>

typedef long long lld;
const lld mod = 1000000007;

struct mat {
	lld ba[9][9];
	mat operator* (const mat &c){
		mat res; memset(res.ba, 0, sizeof(res.ba));
		for(int i=0; i<9; i++){
			for(int j=0; j<9; j++){
				for(int k=0; k<9; k++) res.ba[i][j] += ba[i][k]*c.ba[k][j];
				res.ba[i][j] %= mod;
			}
		}
		return res;
	}
} base, res;

int N;

int main(){
	scanf("%d", &N); N-=4;
	if(N<0){ puts("4"); return 0; }
	memset(base.ba, 0, sizeof(base.ba));
	memset(res.ba, 0, sizeof(res.ba));
	for(int i=0; i<9; i++) res.ba[i][i] = 1;
	base.ba[0][0] = base.ba[0][1] = base.ba[0][2] = base.ba[0][3] = 1;
	base.ba[1][4] = base.ba[1][5] = base.ba[2][6] = base.ba[3][7] = base.ba[3][8] = 1;
	base.ba[4][0] = base.ba[4][2] = base.ba[4][3] = 1;
	base.ba[6][0] = base.ba[6][1] = base.ba[6][3] = 1;
	base.ba[7][0] = base.ba[7][1] = base.ba[7][2] = 1;
	base.ba[5][7] = base.ba[8][4] = 1;

	for(; N; N>>=1){
		if(N&1) res = res*base;
		base = base*base;
	}

	lld sum=0;
	for(int i=0; i<9; i++){
		for(int j=0; j<9; j++) sum += res.ba[i][j];
	}
	printf("%lld\n", sum%mod);
	return 0;
}

Compilation message

cross.cpp: In function 'int main()':
cross.cpp:24:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &N); N-=4;
  ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 420 KB Output is correct
5 Correct 2 ms 572 KB Output is correct
6 Correct 3 ms 572 KB Output is correct
7 Correct 3 ms 572 KB Output is correct
8 Correct 2 ms 572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 420 KB Output is correct
5 Correct 2 ms 572 KB Output is correct
6 Correct 3 ms 572 KB Output is correct
7 Correct 3 ms 572 KB Output is correct
8 Correct 2 ms 572 KB Output is correct
9 Correct 2 ms 572 KB Output is correct
10 Correct 3 ms 572 KB Output is correct
11 Correct 2 ms 572 KB Output is correct
12 Correct 2 ms 572 KB Output is correct
13 Correct 2 ms 572 KB Output is correct
14 Correct 2 ms 604 KB Output is correct
15 Correct 3 ms 604 KB Output is correct
16 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 420 KB Output is correct
5 Correct 2 ms 572 KB Output is correct
6 Correct 3 ms 572 KB Output is correct
7 Correct 3 ms 572 KB Output is correct
8 Correct 2 ms 572 KB Output is correct
9 Correct 2 ms 572 KB Output is correct
10 Correct 3 ms 572 KB Output is correct
11 Correct 2 ms 572 KB Output is correct
12 Correct 2 ms 572 KB Output is correct
13 Correct 2 ms 572 KB Output is correct
14 Correct 2 ms 604 KB Output is correct
15 Correct 3 ms 604 KB Output is correct
16 Correct 2 ms 604 KB Output is correct
17 Correct 2 ms 604 KB Output is correct
18 Correct 3 ms 604 KB Output is correct
19 Correct 3 ms 604 KB Output is correct
20 Correct 3 ms 604 KB Output is correct
21 Correct 3 ms 604 KB Output is correct
22 Correct 2 ms 604 KB Output is correct
23 Correct 3 ms 604 KB Output is correct
24 Correct 2 ms 604 KB Output is correct
25 Correct 2 ms 604 KB Output is correct