第十七次csp认证第二题

没有注意看题给的数据数量,我按照数据量十分大得情况写的,可以直接将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;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值