Submission #135545

# Submission time Handle Problem Language Result Execution time Memory
135545 2019-07-24T07:56:39 Z 이온조(#3249) A Huge Tower (CEOI10_tower) C++14
40 / 100
1000 ms 95164 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)));
		ret %= MOD;
	}
	return dp[ls][msk] = ret;
}

int main() {
	scanf("%d%d",&N,&D);
	assert(N <= 20);
	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:20: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:22: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 95096 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 81 ms 95024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 89 ms 95116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 82 ms 95012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 114 ms 95160 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 258 ms 95072 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1073 ms 94968 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Correct 104 ms 95140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 215 ms 95164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 476 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 440 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -