Submission #8042527


Source Code Expand

Copy
#include<bits/stdc++.h>
using namespace std;

char str[43][43]; long long ans , dp[43][43][43] , N;

long long dfs(int l , int mid , int r){
	if(l == r) return 1;
	if(l == mid || r == mid) return 0;
	if(dp[l][mid][r] != -1) return dp[l][mid][r];
	dp[l][mid][r] = 0;
	for(int j = l ; j < mid ; ++j)
		for(int k = mid + 1 ; k <= r ; ++k)
			if(str[j][k] == '1')
				for(int p = j ; p < mid ; ++p)
					for(int q = mid + 1 ; q <= k ; ++q)
						dp[l][mid][r] += dfs(l , j , p) * dfs(p + 1 , mid , q - 1) * dfs(q , k , r);
	return dp[l][mid][r];
}

int main(){
	memset(dp , -1 , sizeof(dp));
	scanf("%lld" , &N); for(int i = 1 ; i <= 2 * N ; ++i) scanf("%s" , str[i] + 1);
	for(int i = 3 ; i <= 2 * N - 1 ; ++i) if(str[1][i] == '1') ans += dfs(2 , i ,  2 * N);
	cout << ans; return 0;
}

Submission Info

Submission Time
Task E - Pairing Points
User Itst
Language C++14 (GCC 5.4.1)
Score 0
Code Size 806 Byte
Status WA
Exec Time 360 ms
Memory 896 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:22:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld" , &N); for(int i = 1 ; i <= 2 * N ; ++i) scanf("%s" , str[i] + 1);
                    ^
./Main.cpp:22:80: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld" , &N); for(int i = 1 ; i <= 2 * N ; ++i) scanf("%s" , str[i] + 1);
                                                                                ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 1500
Status
AC × 3
AC × 27
WA × 1
Set Name Test Cases
Sample s1.txt, s2.txt, s3.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, s1.txt, s2.txt, s3.txt
Case Name Status Exec Time Memory
01.txt AC 250 ms 896 KB
02.txt AC 360 ms 896 KB
03.txt AC 247 ms 896 KB
04.txt AC 339 ms 896 KB
05.txt AC 237 ms 896 KB
06.txt AC 343 ms 896 KB
07.txt AC 239 ms 896 KB
08.txt AC 340 ms 896 KB
09.txt AC 241 ms 896 KB
10.txt AC 347 ms 896 KB
11.txt AC 241 ms 896 KB
12.txt AC 344 ms 896 KB
13.txt AC 249 ms 896 KB
14.txt AC 350 ms 896 KB
15.txt AC 46 ms 896 KB
16.txt AC 2 ms 896 KB
17.txt AC 5 ms 896 KB
18.txt AC 4 ms 896 KB
19.txt AC 3 ms 896 KB
20.txt AC 151 ms 896 KB
21.txt AC 88 ms 896 KB
22.txt AC 1 ms 896 KB
23.txt WA 2 ms 896 KB
24.txt AC 2 ms 896 KB
25.txt AC 2 ms 896 KB
s1.txt AC 2 ms 896 KB
s2.txt AC 2 ms 896 KB
s3.txt AC 2 ms 896 KB