没有注意看题给的数据数量,我按照数据量十分大得情况写的,可以直接将E存到数组中,
#include<iostream>
#include<vector>
#include<cstring>
using namespace std;
int main() {
int N;
cin >> N;
long long int temp1,temp2,temp3;
int charge[5];
memset(charge, 0, sizeof(int));
long long int goal_num = 0,goal_D = 0,goal_E = 0;
bool charge_l = false;//初始化未false,有符合结果之后变成true
int charge_E[3];
memset(charge_E, 0, sizeof(int));
long long int q = 0;
int k = 0;
for (int i = 0; i < N; i++) {
cin >> temp1;
charge_l = false;
temp2 = 0;
temp3 = 0;
k = q % 3;
charge_E[k] = 0;
charge_E[k] = 0;
for (int j = 0; j < temp1; j++) {
cin >> temp2;
if (j == 0) {
temp3 = temp2;
}
else {
if (temp2 > 0 && !charge_l && temp3 != temp2) {
goal_D++;
temp3 = temp2;
if (i == 0 || i == 1 ) {
charge[i] = 1;
}
if (i == N - 2 ) {
charge[2] = 1;
}
if (i == N - 1) {
charge[3] = 1;
}
charge_l = true;
charge_E[k] = 1;
}
if (temp2 > 0 && charge_l) {
temp3 = temp2;
}
if (temp2 <= 0) {
temp3 += temp2;
}
}
}
q++;
if (charge_E[0] == 1 && charge_E[1] == 1 && charge_E[2] == 1)
goal_E++;
goal_num += temp3;
}
if (charge[2] == 1 && charge[3] == 1 && charge[0] == 1)
goal_E++;
if (charge[1] == 1 && charge[3] == 1 && charge[0] == 1)
goal_E++;
cout << goal_num << " " << goal_D << " " << goal_E << endl;
return 0;
}