Submission #373827


Source Code Expand

#include <cstdio>
int a[100];
const int C = 27*27*27*3;
int dp[60][C];
char s[100];
const int mod = 1000000007;
inline void add(int &v, int t) {
	v += t;
	if (v >= mod) v -= mod;
}
int main() {
	int n, x, p, l, r;
	scanf("%d%d%d", &n, &x, &p);
	dp[0][0] = 1;
	int ok[11], f = 1, ans = 0;
	for (int i = 0; i < n; i++) {
		scanf("%s", s);
		if (s[0] == '?') {
			l = 0; r = p;
		} else {
			l = 0;
			for (int j = 0; s[j]; j++) {
				l = l * 10 + s[j] - '0';
			}
			r = l;
			if (l == 0) {
				f = 0;
			}
		}
		if (l == 0) ++l;
		for (int j = 0; j < C; j++) {
			int t = j;
			if (!dp[i][j]) continue;
			for (int k = 0; k < x; k++) {
				ok[k] = t % 3;
				t /= 3;
			}
			for (int k = l; k <= r; k++) {
				int nt = 0, z;
				for (int y = x - 1; y >= 0; y--) {
					z = ok[y];
					if (y + 1 - k == 0) {
						z++;
					} else if (y + 1 - k > 0) {
						z += ok[y-k];
					}
					if (z >= 2) {
						nt = nt * 3 + 2;
					} else if (z == 1) {
						nt = nt * 3 + 1;
					} else {
						nt = nt * 3;
					}
				}
				add(dp[i+1][nt], dp[i][j]);
			}
		}
	}
	if (!f) {
		puts("0");
	} else {
		for (int j = 0; j < C; j++) {
			int t = j;
			for (int k = 0; k < x; k++) {
				ok[k] = t % 3;
				t /= 3;
			}
			if (ok[x-1] == 1) {
				add(ans, dp[n][j]);
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

Submission Info

Submission Time
Task G - 唯一の組み合わせ
User greentea
Language C++ (GCC 4.9.2)
Score 200
Code Size 1377 Byte
Status AC
Exec Time 193 ms
Memory 11672 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:13:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d", &n, &x, &p);
                             ^
./Main.cpp:17:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s", s);
                 ^

Judge Result

Set Name All
Score / Max Score 200 / 200
Status
AC × 28
Set Name Test Cases
All scrambled_00.txt, scrambled_01.txt, scrambled_02.txt, scrambled_03.txt, scrambled_04.txt, scrambled_05.txt, scrambled_06.txt, scrambled_07.txt, scrambled_08.txt, scrambled_09.txt, scrambled_10.txt, scrambled_11.txt, scrambled_12.txt, scrambled_13.txt, scrambled_14.txt, scrambled_15.txt, scrambled_16.txt, scrambled_17.txt, scrambled_18.txt, scrambled_19.txt, scrambled_20.txt, scrambled_21.txt, scrambled_22.txt, scrambled_23.txt, scrambled_24.txt, scrambled_25.txt, scrambled_26.txt, scrambled_27.txt
Case Name Status Exec Time Memory
scrambled_00.txt AC 24 ms 716 KiB
scrambled_01.txt AC 25 ms 676 KiB
scrambled_02.txt AC 25 ms 800 KiB
scrambled_03.txt AC 23 ms 800 KiB
scrambled_04.txt AC 26 ms 764 KiB
scrambled_05.txt AC 25 ms 796 KiB
scrambled_06.txt AC 28 ms 792 KiB
scrambled_07.txt AC 25 ms 792 KiB
scrambled_08.txt AC 29 ms 784 KiB
scrambled_09.txt AC 27 ms 676 KiB
scrambled_10.txt AC 26 ms 672 KiB
scrambled_11.txt AC 28 ms 796 KiB
scrambled_12.txt AC 42 ms 1696 KiB
scrambled_13.txt AC 25 ms 684 KiB
scrambled_14.txt AC 137 ms 11416 KiB
scrambled_15.txt AC 41 ms 1056 KiB
scrambled_16.txt AC 32 ms 796 KiB
scrambled_17.txt AC 31 ms 672 KiB
scrambled_18.txt AC 35 ms 804 KiB
scrambled_19.txt AC 28 ms 660 KiB
scrambled_20.txt AC 31 ms 920 KiB
scrambled_21.txt AC 26 ms 688 KiB
scrambled_22.txt AC 23 ms 700 KiB
scrambled_23.txt AC 25 ms 668 KiB
scrambled_24.txt AC 28 ms 668 KiB
scrambled_25.txt AC 62 ms 4520 KiB
scrambled_26.txt AC 59 ms 3492 KiB
scrambled_27.txt AC 193 ms 11672 KiB