Problem: http://codeforces.com/contest/754/problem/A
Code:
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long ar[1000],i,n,x,sum,f,m;
while(cin>>n)
{
sum=0;
m=n;
f=0;
while(m--)
{
cin>>x;
sum+=x;
if(x)
{
f=n-m-1;
}
}
if(sum !=0)
{
cout<<"YES"<<endl;
cout<<1<<endl<<1<<" "<<n<<endl;
}
else if(f)
{
cout<<"YES"<<endl;
cout<<2<<endl<<1<<" "<<f<<endl<<f+1<<" "<<n<<endl;
}
else
cout<<"NO\n";
}
return 0;
}
Code:
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long ar[1000],i,n,x,sum,f,m;
while(cin>>n)
{
sum=0;
m=n;
f=0;
while(m--)
{
cin>>x;
sum+=x;
if(x)
{
f=n-m-1;
}
}
if(sum !=0)
{
cout<<"YES"<<endl;
cout<<1<<endl<<1<<" "<<n<<endl;
}
else if(f)
{
cout<<"YES"<<endl;
cout<<2<<endl<<1<<" "<<f<<endl<<f+1<<" "<<n<<endl;
}
else
cout<<"NO\n";
}
return 0;
}
No comments:
Post a Comment