답안 #20424

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
20424 2017-02-11T11:18:40 Z tlwpdus(#44, tlwpdus) 복불복 (OJUZ11_luck) C++
13 / 100
413 ms 3164 KB
// k==1

#include<stdio.h>
#include<algorithm>
#include<vector>
#include<math.h>
#include<queue>
 
using namespace std;
 
typedef long long ll;

const ll MOD = 1000000007;
ll res = 0;
int n, k;
int a[110];
int b[110];
ll po[200][200];

ll dap[110];
ll inv[110];
ll tmp[110];
void calc(const vector<ll> &vec) {
	int i, j;
	for (i=1;i<=vec.size();i++) {
		for (j=0;j<vec.size();j++) {
			tmp[i] += po[vec[j]][i];
			tmp[i] %= MOD;
		}
	}
	dap[0] = 1;
	for (i=1;i<=vec.size();i++) {
		dap[i] = 0;
		for (j=1;j<=i;j++) {
			ll st = ((j-1)%2)?(-1):1;
			dap[i] += (st*dap[i-j]*tmp[j])%MOD;
			dap[i] %= MOD;
		}
		dap[i] *= inv[i];
		dap[i] = ((dap[i]%MOD)+MOD)%MOD;
	}
}

ll popo(ll a, ll n) {
	if (n==0) return 1;
	ll val = popo(a,n/2);
	if (n%2) return (((val*val)%MOD)*a)%MOD;
	return (val*val)%MOD;
}

void pre() {
	int i;
	for (i=1;i<110;i++) inv[i] = popo(i,MOD-2);
}

ll dyn[2010][110];

int pp[20];
int arr[20];
int main() {
	int i, j, l;
	scanf("%d%d",&n,&k);
	for (i=0;i<n;i++) scanf("%d",&a[i]);
	for (i=0;i<n;i++) scanf("%d",&b[i]);
	sort(a,a+n); sort(b,b+n);
	if (k==1) {
		for (i=0;i<n;i++) {
			int v = a[n-1]+b[i];
			ll tres = 1;
			for (j=n-2;j>=0;j--) {
				int cnt = 0;
				for (l=0;l<n;l++) {
					if (l==i) continue;
					if (a[j]+b[l]>v) break;
					cnt++;
				}
				if (cnt<=n-2-j) {
					tres = 0;
					break;
				}
				tres *= cnt-(n-2-j);
				tres %= MOD;
			}
			res += tres;
			res %= MOD;
		}
		printf("%lld\n",res);
	}
	else if (n<=10) {
		res = 0;
		for (i=0;i<n;i++) pp[i] = i;
		do {
			bool flag = true;
			for (i=0;i<n;i++) arr[i] = a[i]+b[pp[i]];
			for (i=n-k;i<n;i++) {
				int cnt = 1;
				for (j=0;j<n;j++) {
					if (arr[i]<arr[j]) cnt++;
				}
				if (cnt>k) flag = false;
			}
			if (flag) res++;
		} while (next_permutation(pp,pp+n));
		printf("%lld\n",res%MOD);
	}
	else {
		int a = 0;
		printf("%d\n",1/a);
	}

	return 0;
}

Compilation message

luck.cpp: In function 'void calc(const std::vector<long long int>&)':
luck.cpp:25:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (i=1;i<=vec.size();i++) {
            ^
luck.cpp:26:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (j=0;j<vec.size();j++) {
             ^
luck.cpp:32:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (i=1;i<=vec.size();i++) {
            ^
luck.cpp: In function 'int main()':
luck.cpp:62:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&k);
                     ^
luck.cpp:63:37: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (i=0;i<n;i++) scanf("%d",&a[i]);
                                     ^
luck.cpp:64:37: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (i=0;i<n;i++) scanf("%d",&b[i]);
                                     ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 3164 KB Output is correct
2 Incorrect 0 ms 3164 KB Output isn't correct
3 Correct 0 ms 3164 KB Output is correct
4 Incorrect 0 ms 3164 KB Output isn't correct
5 Correct 0 ms 3164 KB Output is correct
6 Correct 3 ms 3164 KB Output is correct
7 Correct 0 ms 3164 KB Output is correct
8 Correct 0 ms 3164 KB Output is correct
9 Correct 0 ms 3164 KB Output is correct
10 Incorrect 0 ms 3164 KB Output isn't correct
11 Incorrect 0 ms 3164 KB Output isn't correct
12 Correct 0 ms 3164 KB Output is correct
13 Correct 0 ms 3164 KB Output is correct
14 Correct 0 ms 3164 KB Output is correct
15 Correct 0 ms 3164 KB Output is correct
16 Correct 0 ms 3164 KB Output is correct
17 Correct 0 ms 3164 KB Output is correct
18 Correct 0 ms 3164 KB Output is correct
19 Correct 0 ms 3164 KB Output is correct
20 Correct 0 ms 3164 KB Output is correct
21 Correct 0 ms 3164 KB Output is correct
22 Correct 0 ms 3164 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 3164 KB Output is correct
2 Correct 0 ms 3164 KB Output is correct
3 Correct 0 ms 3164 KB Output is correct
4 Correct 0 ms 3164 KB Output is correct
5 Correct 0 ms 3164 KB Output is correct
6 Correct 0 ms 3164 KB Output is correct
7 Correct 0 ms 3164 KB Output is correct
8 Correct 0 ms 3164 KB Output is correct
9 Correct 0 ms 3164 KB Output is correct
10 Correct 0 ms 3164 KB Output is correct
11 Correct 0 ms 3164 KB Output is correct
12 Correct 0 ms 3164 KB Output is correct
13 Correct 0 ms 3164 KB Output is correct
14 Correct 0 ms 3164 KB Output is correct
15 Correct 0 ms 3164 KB Output is correct
16 Correct 0 ms 3164 KB Output is correct
17 Correct 0 ms 3164 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 3164 KB Output is correct
2 Incorrect 0 ms 3164 KB Output isn't correct
3 Correct 0 ms 3164 KB Output is correct
4 Incorrect 0 ms 3164 KB Output isn't correct
5 Correct 0 ms 3164 KB Output is correct
6 Correct 3 ms 3164 KB Output is correct
7 Correct 0 ms 3164 KB Output is correct
8 Correct 0 ms 3164 KB Output is correct
9 Correct 0 ms 3164 KB Output is correct
10 Incorrect 0 ms 3164 KB Output isn't correct
11 Incorrect 0 ms 3164 KB Output isn't correct
12 Correct 0 ms 3164 KB Output is correct
13 Correct 0 ms 3164 KB Output is correct
14 Correct 0 ms 3164 KB Output is correct
15 Correct 0 ms 3164 KB Output is correct
16 Correct 0 ms 3164 KB Output is correct
17 Correct 0 ms 3164 KB Output is correct
18 Correct 0 ms 3164 KB Output is correct
19 Correct 0 ms 3164 KB Output is correct
20 Correct 0 ms 3164 KB Output is correct
21 Correct 0 ms 3164 KB Output is correct
22 Correct 0 ms 3164 KB Output is correct
23 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
24 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
25 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
26 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
27 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
28 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
29 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
30 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
31 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
32 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
33 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
34 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
35 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
36 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
37 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
38 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
39 Correct 0 ms 3164 KB Output is correct
40 Correct 0 ms 3164 KB Output is correct
41 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
42 Correct 19 ms 3164 KB Output is correct
43 Correct 413 ms 3164 KB Output is correct
44 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
45 Correct 0 ms 3164 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 3164 KB Output is correct
2 Incorrect 0 ms 3164 KB Output isn't correct
3 Correct 0 ms 3164 KB Output is correct
4 Incorrect 0 ms 3164 KB Output isn't correct
5 Correct 0 ms 3164 KB Output is correct
6 Correct 3 ms 3164 KB Output is correct
7 Correct 0 ms 3164 KB Output is correct
8 Correct 0 ms 3164 KB Output is correct
9 Correct 0 ms 3164 KB Output is correct
10 Incorrect 0 ms 3164 KB Output isn't correct
11 Incorrect 0 ms 3164 KB Output isn't correct
12 Correct 0 ms 3164 KB Output is correct
13 Correct 0 ms 3164 KB Output is correct
14 Correct 0 ms 3164 KB Output is correct
15 Correct 0 ms 3164 KB Output is correct
16 Correct 0 ms 3164 KB Output is correct
17 Correct 0 ms 3164 KB Output is correct
18 Correct 0 ms 3164 KB Output is correct
19 Correct 0 ms 3164 KB Output is correct
20 Correct 0 ms 3164 KB Output is correct
21 Correct 0 ms 3164 KB Output is correct
22 Correct 0 ms 3164 KB Output is correct
23 Correct 0 ms 3164 KB Output is correct
24 Correct 0 ms 3164 KB Output is correct
25 Correct 0 ms 3164 KB Output is correct
26 Correct 0 ms 3164 KB Output is correct
27 Correct 0 ms 3164 KB Output is correct
28 Correct 0 ms 3164 KB Output is correct
29 Correct 0 ms 3164 KB Output is correct
30 Correct 0 ms 3164 KB Output is correct
31 Correct 0 ms 3164 KB Output is correct
32 Correct 0 ms 3164 KB Output is correct
33 Correct 0 ms 3164 KB Output is correct
34 Correct 0 ms 3164 KB Output is correct
35 Correct 0 ms 3164 KB Output is correct
36 Correct 0 ms 3164 KB Output is correct
37 Correct 0 ms 3164 KB Output is correct
38 Correct 0 ms 3164 KB Output is correct
39 Correct 0 ms 3164 KB Output is correct
40 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
41 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
42 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
43 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
44 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
45 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
46 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
47 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
48 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
49 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
50 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
51 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
52 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
53 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
54 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
55 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
56 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
57 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
58 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
59 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 3164 KB Output is correct
2 Incorrect 0 ms 3164 KB Output isn't correct
3 Correct 0 ms 3164 KB Output is correct
4 Incorrect 0 ms 3164 KB Output isn't correct
5 Correct 0 ms 3164 KB Output is correct
6 Correct 3 ms 3164 KB Output is correct
7 Correct 0 ms 3164 KB Output is correct
8 Correct 0 ms 3164 KB Output is correct
9 Correct 0 ms 3164 KB Output is correct
10 Incorrect 0 ms 3164 KB Output isn't correct
11 Incorrect 0 ms 3164 KB Output isn't correct
12 Correct 0 ms 3164 KB Output is correct
13 Correct 0 ms 3164 KB Output is correct
14 Correct 0 ms 3164 KB Output is correct
15 Correct 0 ms 3164 KB Output is correct
16 Correct 0 ms 3164 KB Output is correct
17 Correct 0 ms 3164 KB Output is correct
18 Correct 0 ms 3164 KB Output is correct
19 Correct 0 ms 3164 KB Output is correct
20 Correct 0 ms 3164 KB Output is correct
21 Correct 0 ms 3164 KB Output is correct
22 Correct 0 ms 3164 KB Output is correct
23 Correct 0 ms 3164 KB Output is correct
24 Correct 0 ms 3164 KB Output is correct
25 Correct 0 ms 3164 KB Output is correct
26 Correct 0 ms 3164 KB Output is correct
27 Correct 0 ms 3164 KB Output is correct
28 Correct 0 ms 3164 KB Output is correct
29 Correct 0 ms 3164 KB Output is correct
30 Correct 0 ms 3164 KB Output is correct
31 Correct 0 ms 3164 KB Output is correct
32 Correct 0 ms 3164 KB Output is correct
33 Correct 0 ms 3164 KB Output is correct
34 Correct 0 ms 3164 KB Output is correct
35 Correct 0 ms 3164 KB Output is correct
36 Correct 0 ms 3164 KB Output is correct
37 Correct 0 ms 3164 KB Output is correct
38 Correct 0 ms 3164 KB Output is correct
39 Correct 0 ms 3164 KB Output is correct
40 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
41 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
42 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
43 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
44 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
45 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
46 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
47 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
48 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
49 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
50 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
51 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
52 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
53 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
54 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
55 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
56 Correct 0 ms 3164 KB Output is correct
57 Correct 0 ms 3164 KB Output is correct
58 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
59 Correct 19 ms 3164 KB Output is correct
60 Correct 413 ms 3164 KB Output is correct
61 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
62 Correct 0 ms 3164 KB Output is correct
63 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
64 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
65 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
66 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
67 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
68 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
69 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
70 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
71 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
72 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
73 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
74 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
75 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
76 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
77 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
78 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
79 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
80 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
81 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
82 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
83 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
84 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
85 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
86 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
87 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
88 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
89 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
90 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
91 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
92 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
93 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
94 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
95 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
96 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
97 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
98 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
99 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
100 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
101 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
102 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
103 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
104 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
105 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
106 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)
107 Runtime error 0 ms 3164 KB Execution killed with signal 8 (could be triggered by violating memory limits)