求大佬改进:H题——本题主要考察了DFS

我思路是对的,但一直超时。想来想去也不知道怎么减少时间复杂度。。。

#include <iostream>

#include <math.h>

#include <iomanip>

using namespace std;

int main()

{

int t,n, x,y;

int b[20];

char a[400][4];

cin >> t;

int t1 = t;

while (t)

{

cin >> n;

x = 0;

y = 0;

b[t1 - t] = 0;

for (int i = 1; i < n * n; i++)

for (int j = 1; j <= 4; j++)

{

cin >> a[i][j];

if (a[i][j] == '1')

x++;

if (a[i][j] == '2')

x--;

}

b[t1-t]= 10 + x;

t--;

}

for (int i=0;i<t1;i++)

{

cout << b[i];

}

return 0;

}

全部评论
小白路过一下
点赞 回复 分享
发布于 2023-01-30 17:45 未知

相关推荐

漂亮的海豚在炒股:把西电加粗
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
正在热议
更多
牛客网
牛客企业服务