Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <math.h>
- using namespace std;
- ifstream cin("soricel.in");
- ofstream cout("soricel.out");
- int v[200][200];
- int main()
- {
- int cer,n,m,k,lin,col,max1,cnt,a,la,s,e,mis,ci;
- cin>>cer>>n>>m>>k;
- max1=1;
- cnt=0;
- for(lin=0;lin<n;lin++){
- for(col=0;col<m;col++){
- cin>>v[lin][col];
- if(v[lin][col]>1){
- a=sqrt(v[lin][col]-1);
- v[lin][col]-=a*a;
- }else{
- v[lin][col]=0;
- }
- ///cer 1
- if(v[lin][col]>max1)
- max1=v[lin][col];
- if(v[lin][col]==k)
- cnt++;
- }
- }
- if(cer==1)
- cout<<max1<<endl<<cnt;
- else{
- la=v[0][0];
- ci=0;
- cnt=0;
- max1=0;
- for(lin=0;lin<n;lin++){
- if(lin%2==0){
- s=0;
- e=m-1;
- mis=1;
- }else{
- s=m-1;
- e=0;
- mis=-1;
- }
- col=s;
- while(col!=e){
- if(v[lin][col]==la){
- cnt++;
- }else{
- if(cnt+1>max1 && la>0){
- ci=la;
- max1=cnt+1;
- }else if (cnt+1==max1 && la>=ci){
- ci=la;
- max1=cnt+1;
- }
- cnt=1;
- }
- la=v[lin][col];
- col+=mis;
- }
- }
- cout<<max1<<endl<<ci;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment