题目确实简单,但是一直告诉我超时通过率为14%,有人和我一样情况吗?或者谁能帮我解答一下原因?
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main()
{
int n;
cin >> n;
int k = 0;
while (k < n)
{
int m;
cin >> m;
vector<long long> vec(m,99999999);
vector<char> res(m);
for (int i = 0; i < m; ++i)
{
for (int j = 0; j < m; ++j)
{
int d = 0;
scanf("%d", &d);
if (d < vec[j])
{
vec[j] = d;
char c;
if (i == 0)
res[j] = 'E';
else if (i == 1)
res[j] = 'S';
else if (i == 2)
res[j] = 'W';
else if (i == 3)
res[j] = 'N';
}
}
}
long long sum = 0;
char *res1 = new char[m];
for (int j = 0; j < m; ++j)
{
sum += vec[j];
res1[j] = res[j];
}
res1[m] = '\0';
printf("%d\n",sum);
printf("%s\n",res1);
k++;
}
return 0;
}