题目描述
blablabla
样例
blablabla
算法1
(暴力枚举) $O(n^2)$
blablabla
时间复杂度
参考文献
C++ 代码
blablabla
算法2
(暴力枚举) $O(n^2)$
blablabla
时间复杂度
参考文献
C++ 代码
#include<bits/stdc++.h>
using namespace std;
const int N = 10100;
struct Node
{
int st;
int flag = 1;
}node[N];
int n;
int main()
{
cin>>n;
int res = 0;
int D = 0;
int E = 0;
for(int i = 1;i <= n;i++)
{
int m = 0;
int re = 0;
cin>>m;
int pos = 1;
while(pos <= m)
{
int x;
cin>>x;
if(pos == 1)
{
node[i].st = x;
}
else
{
if(x > 0)
{
if(node[i].st - re != x)
{
node[i].flag = 0;
}
node[i].st = x;
re = 0;
}
else
{
re += abs(x);
}
}
pos++;
}
res += node[i].st - re;
}
for(int i = 1;i <= n;i++)
{
if(node[i].flag == 0)
{
D++;
}
}
node[n + 1].flag = node[1].flag;
node[n + 2].flag = node[2].flag;
for(int i = 1;i <= n;i++)
{
if(node[i].flag == 0 && node[i + 1].flag == 0 && node[i + 2].flag == 0)
{
E++;
}
}
cout<<res<<" "<<D<<" "<<E<<endl;
return 0;
}