#include <bits/stdc++.h>
using namespace std;
int main()
{
int N;
cin>>N;
vector<vector<int>> apples;
for(int i=0;i<N;i++)
{
int n;
cin>>n;
vector<int> tmp;
for(int j=0;j<n;j++)
{
int num;
cin>>num;
tmp.push_back(num);
}
apples.push_back(tmp);
}
long long T=0;
int D=0;
int E=0;
vector<int> luoguo;
for(int i=0;i<N;i++)
{
int sum=apples[i][0];
int flag=0;
for(int j=1;j<apples[i].size();j++)
{
if(apples[i][j]<=0)
sum+=apples[i][j];
else if(sum!=apples[i][j])
{
sum=apples[i][j];
if(flag==0)
{
luoguo.push_back(i+1);
flag=1;
}
}
}
T+=sum;
}
D=luoguo.size();
if(D<3)
E=0;
else
{
for(int i=0;i<D;i++)
{
int a=luoguo[i];
int b=(luoguo[(i+1)%D])%N;
int c=(luoguo[(i+2)%D])%N;
if((a+1)%N!=b)
continue;
else if((a+2)%N!=c)
i=i+1;
else
{
E++;
}
}
}
cout<<T<<" "<<D<<" "<<E;
return 0;
}
|