Submission #255667

# Submission time Handle Problem Language Result Execution time Memory
255667 2020-08-01T13:47:06 Z blacktulip Zapina (COCI20_zapina) C++17
110 / 110
405 ms 2936 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define mp make_pair
#define endl "\n"
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo inf = 1000000000000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 353;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,t,comb[li][li],dp[li][li][4];
int cev;
string s;
vector<int> v;

inline int add(int x,int y){
	if(x+y>=mod)return x+y-mod;
	return x+y;
}

inline int mul(int x,int y){
	return (x%mod)*(y%mod)%mod;
}

inline int f(int sira,int how,int flag){
	int cevv=0;
	if(how<0)return 0;
	if(how==0)return flag;
	if(sira>n){
		return 0;
	}
	if(~dp[sira][how][flag])return dp[sira][how][flag];
	for(int i=0;i<=how;i++){
		cevv=add(cevv,mul(comb[how][i],f(sira+1,how-i,flag|(sira==i?1:0))));
	}
	return dp[sira][how][flag]=cevv;
}

int main(void){
	memset(dp,-1,sizeof(dp));
	scanf("%d",&n);
	comb[0][0]=1;
	FOR{
		for(int j=0;j<=n;j++){
			comb[i][j]=comb[i-1][j];
			if(j)comb[i][j]=add(comb[i][j],comb[i-1][j-1]);
		}
	}
	printf("%d\n",f(1,n,0));
	return 0;
}

Compilation message

zapina.cpp: In function 'int main()':
zapina.cpp:54:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2304 KB Output is correct
2 Correct 1 ms 2304 KB Output is correct
3 Correct 1 ms 2304 KB Output is correct
4 Correct 1 ms 2304 KB Output is correct
5 Correct 1 ms 2304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2304 KB Output is correct
2 Correct 1 ms 2304 KB Output is correct
3 Correct 1 ms 2304 KB Output is correct
4 Correct 1 ms 2304 KB Output is correct
5 Correct 1 ms 2304 KB Output is correct
6 Correct 1 ms 2304 KB Output is correct
7 Correct 1 ms 2304 KB Output is correct
8 Correct 1 ms 2304 KB Output is correct
9 Correct 1 ms 2304 KB Output is correct
10 Correct 1 ms 2304 KB Output is correct
11 Correct 1 ms 2304 KB Output is correct
12 Correct 1 ms 2304 KB Output is correct
13 Correct 2 ms 2304 KB Output is correct
14 Correct 1 ms 2304 KB Output is correct
15 Correct 2 ms 2324 KB Output is correct
16 Correct 2 ms 2304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2304 KB Output is correct
2 Correct 1 ms 2304 KB Output is correct
3 Correct 1 ms 2304 KB Output is correct
4 Correct 1 ms 2304 KB Output is correct
5 Correct 1 ms 2304 KB Output is correct
6 Correct 1 ms 2304 KB Output is correct
7 Correct 1 ms 2304 KB Output is correct
8 Correct 1 ms 2304 KB Output is correct
9 Correct 1 ms 2304 KB Output is correct
10 Correct 1 ms 2304 KB Output is correct
11 Correct 1 ms 2304 KB Output is correct
12 Correct 1 ms 2304 KB Output is correct
13 Correct 2 ms 2304 KB Output is correct
14 Correct 1 ms 2304 KB Output is correct
15 Correct 2 ms 2324 KB Output is correct
16 Correct 2 ms 2304 KB Output is correct
17 Correct 201 ms 2688 KB Output is correct
18 Correct 3 ms 2304 KB Output is correct
19 Correct 44 ms 2432 KB Output is correct
20 Correct 1 ms 2304 KB Output is correct
21 Correct 264 ms 2688 KB Output is correct
22 Correct 29 ms 2516 KB Output is correct
23 Correct 4 ms 2304 KB Output is correct
24 Correct 57 ms 2560 KB Output is correct
25 Correct 38 ms 2432 KB Output is correct
26 Correct 76 ms 2560 KB Output is correct
27 Correct 372 ms 2936 KB Output is correct
28 Correct 372 ms 2808 KB Output is correct
29 Correct 381 ms 2808 KB Output is correct
30 Correct 378 ms 2936 KB Output is correct
31 Correct 381 ms 2936 KB Output is correct
32 Correct 388 ms 2816 KB Output is correct
33 Correct 391 ms 2936 KB Output is correct
34 Correct 390 ms 2936 KB Output is correct
35 Correct 404 ms 2820 KB Output is correct
36 Correct 402 ms 2816 KB Output is correct
37 Correct 405 ms 2816 KB Output is correct