| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Re:这题要笑死个人,TLE了我一个多小时我没找到错误,跟Java一样这么矫情?In Reply To:这题要笑死个人,TLE了我一个多小时我没找到错误,跟Java一样这么矫情? Posted by:qq1250173534 at 2020-03-01 17:51:28 > #include <iostream>
> #include <string.h>
> #include <stdio.h>
> #include <algorithm>
> using namespace std;
> char m[10][10];
> int cnt,n,k;
> int q[10];
> void dfs(int row,int num)
> {
> if(num >= k){
> cnt++;
> return ;
> }
> int i,j;
> for(i = row;i < n;i++){ //我下面传row,这里row+1有什么问题嘛?
> for(j = 0;j < n;j++){
> if(q[j] == 0 && m[i][j] != '.'){
> q[j] = 1;
> dfs(i+1,num+1);
> q[j] = 0;
> }
> }
> }
> }
> int main()
> {
> while(~scanf("%d%d",&n,&k)){
> if(n == -1 && k == -1){
> break;
> }
> for(int i = 0;i < n;i++){
> scanf("%s",m[i]);
> }
> memset(q,0,sizeof(q));
> cnt = 0;
> dfs(0,0);
> printf("%d\n",cnt);
> }
> return 0;
> }
hh
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator