Submission #414104

# Submission time Handle Problem Language Result Execution time Memory
414104 2021-05-30T03:54:40 Z jamezzz Asceticism (JOI18_asceticism) C++14
49 / 100
108 ms 143976 KB
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#include <ext/rope>
using namespace __gnu_cxx;

typedef tree<long long, null_type, less<long long>,
rb_tree_tag, tree_order_statistics_node_update> pbds;
//less_equal for identical elements

//#define DEBUG

#ifdef DEBUG
#define debug(...) printf(__VA_ARGS__);
#else
#define debug(...)
#endif
#define sf scanf
#define pf printf
#define fi first
#define se second
#define pb emplace_back
#define sz(x) (int)x.size()
#define mnto(x,y) x=min(x,(__typeof__(x))y)
#define mxto(x,y) x=max(x,(__typeof__(x))y)
#define INF 1023456789
#define LINF 1023456789123456789
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vll;

#define mod 1000000007
int n,k;
ll m[3005][3005];

ll dp(int i,int s){//u want to add i, have s things alrdy
	if(i==n+1&&s==k)return 1;
	if(i>n)return 0;
	if(m[i][s]!=-1)return m[i][s];
	ll res=dp(i+1,s+1)*(i-s) //start a new chain
			+dp(i+1,s)*s; //add to the end of the chain
	res%=mod;
	return m[i][s]=res;
}

int main(){
	sf("%d%d",&n,&k);
	memset(m,-1,sizeof m);
	pf("%lld\n",dp(1,0));
}

Compilation message

asceticism.cpp: In function 'int main()':
asceticism.cpp:56:4: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   56 |  sf("%d%d",&n,&k);
      |    ^
# Verdict Execution time Memory Grader output
1 Correct 30 ms 70860 KB Output is correct
2 Correct 30 ms 70872 KB Output is correct
3 Correct 29 ms 70928 KB Output is correct
4 Correct 31 ms 70980 KB Output is correct
5 Correct 36 ms 70944 KB Output is correct
6 Correct 32 ms 70904 KB Output is correct
7 Correct 30 ms 70988 KB Output is correct
8 Correct 30 ms 70880 KB Output is correct
9 Correct 35 ms 70888 KB Output is correct
10 Correct 32 ms 70948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 70860 KB Output is correct
2 Correct 30 ms 70872 KB Output is correct
3 Correct 29 ms 70928 KB Output is correct
4 Correct 31 ms 70980 KB Output is correct
5 Correct 36 ms 70944 KB Output is correct
6 Correct 32 ms 70904 KB Output is correct
7 Correct 30 ms 70988 KB Output is correct
8 Correct 30 ms 70880 KB Output is correct
9 Correct 35 ms 70888 KB Output is correct
10 Correct 32 ms 70948 KB Output is correct
11 Correct 35 ms 70924 KB Output is correct
12 Correct 32 ms 70944 KB Output is correct
13 Correct 34 ms 70908 KB Output is correct
14 Correct 31 ms 70968 KB Output is correct
15 Correct 34 ms 71004 KB Output is correct
16 Correct 31 ms 70980 KB Output is correct
17 Correct 30 ms 70888 KB Output is correct
18 Correct 31 ms 70968 KB Output is correct
19 Correct 30 ms 70936 KB Output is correct
20 Correct 32 ms 70852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 70860 KB Output is correct
2 Correct 30 ms 70872 KB Output is correct
3 Correct 29 ms 70928 KB Output is correct
4 Correct 31 ms 70980 KB Output is correct
5 Correct 36 ms 70944 KB Output is correct
6 Correct 32 ms 70904 KB Output is correct
7 Correct 30 ms 70988 KB Output is correct
8 Correct 30 ms 70880 KB Output is correct
9 Correct 35 ms 70888 KB Output is correct
10 Correct 32 ms 70948 KB Output is correct
11 Correct 35 ms 70924 KB Output is correct
12 Correct 32 ms 70944 KB Output is correct
13 Correct 34 ms 70908 KB Output is correct
14 Correct 31 ms 70968 KB Output is correct
15 Correct 34 ms 71004 KB Output is correct
16 Correct 31 ms 70980 KB Output is correct
17 Correct 30 ms 70888 KB Output is correct
18 Correct 31 ms 70968 KB Output is correct
19 Correct 30 ms 70936 KB Output is correct
20 Correct 32 ms 70852 KB Output is correct
21 Correct 41 ms 71004 KB Output is correct
22 Correct 42 ms 70996 KB Output is correct
23 Correct 44 ms 71020 KB Output is correct
24 Correct 43 ms 71028 KB Output is correct
25 Correct 47 ms 70988 KB Output is correct
26 Correct 46 ms 70980 KB Output is correct
27 Correct 42 ms 71020 KB Output is correct
28 Correct 35 ms 70948 KB Output is correct
29 Correct 31 ms 70992 KB Output is correct
30 Correct 42 ms 70980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 70860 KB Output is correct
2 Correct 30 ms 70872 KB Output is correct
3 Correct 29 ms 70928 KB Output is correct
4 Correct 31 ms 70980 KB Output is correct
5 Correct 36 ms 70944 KB Output is correct
6 Correct 32 ms 70904 KB Output is correct
7 Correct 30 ms 70988 KB Output is correct
8 Correct 30 ms 70880 KB Output is correct
9 Correct 35 ms 70888 KB Output is correct
10 Correct 32 ms 70948 KB Output is correct
11 Correct 35 ms 70924 KB Output is correct
12 Correct 32 ms 70944 KB Output is correct
13 Correct 34 ms 70908 KB Output is correct
14 Correct 31 ms 70968 KB Output is correct
15 Correct 34 ms 71004 KB Output is correct
16 Correct 31 ms 70980 KB Output is correct
17 Correct 30 ms 70888 KB Output is correct
18 Correct 31 ms 70968 KB Output is correct
19 Correct 30 ms 70936 KB Output is correct
20 Correct 32 ms 70852 KB Output is correct
21 Correct 41 ms 71004 KB Output is correct
22 Correct 42 ms 70996 KB Output is correct
23 Correct 44 ms 71020 KB Output is correct
24 Correct 43 ms 71028 KB Output is correct
25 Correct 47 ms 70988 KB Output is correct
26 Correct 46 ms 70980 KB Output is correct
27 Correct 42 ms 71020 KB Output is correct
28 Correct 35 ms 70948 KB Output is correct
29 Correct 31 ms 70992 KB Output is correct
30 Correct 42 ms 70980 KB Output is correct
31 Runtime error 108 ms 143976 KB Execution killed with signal 11
32 Halted 0 ms 0 KB -