Submission #135542

# Submission time Handle Problem Language Result Execution time Memory
135542 2019-07-24T07:55:04 Z 이온조(#3249) A Huge Tower (CEOI10_tower) C++14
25 / 100
1000 ms 192248 KB
#include <bits/stdc++.h>
using namespace std;

const int MOD = 1e9 + 9;
int A[22], dp[22][1100000], N, D;

int go(int ls, int msk) {
	if(msk == (msk&-msk)) return 1;
	if(dp[ls][msk] != -1) return dp[ls][msk];
	int ret = 0;
	for(int i=1; i<=N; i++) {
		if(i == ls || A[i] + D < A[ls] || (msk & (1 << (i-1))) == 0) continue;
		ret += go(i, msk - (1 << (ls-1)));
	}
	return dp[ls][msk] = ret;
}

int main() {
	scanf("%d%d",&N,&D);
	for(int i=1; i<=N; i++) scanf("%d",&A[i]);
	int ans = 0;
	memset(dp, -1, sizeof(dp));
	for(int i=1; i<=N; i++) ans += go(i, (1 << N) - 1), ans %= MOD;
	printf("%d", ans);
	return 0;
}

Compilation message

tower.cpp: In function 'int main()':
tower.cpp:19:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&N,&D);
  ~~~~~^~~~~~~~~~~~~~
tower.cpp:20:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1; i<=N; i++) scanf("%d",&A[i]);
                          ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 81 ms 94968 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 86 ms 95096 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 101 ms 94968 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 84 ms 95148 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 105 ms 94960 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 247 ms 95044 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1008 ms 95080 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Correct 100 ms 94968 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 197 ms 95056 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Runtime error 226 ms 192228 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Incorrect 82 ms 94964 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Runtime error 212 ms 192120 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 219 ms 192092 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 209 ms 192248 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 211 ms 192120 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 310 ms 192248 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Execution timed out 3 ms 376 KB Time limit exceeded (wall clock)
# Verdict Execution time Memory Grader output
1 Execution timed out 3 ms 376 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3 ms 376 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3 ms 396 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -