Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- using namespace std;
- int ap[100],n,x,y,v,r,c,ci[7];
- int main()
- {
- ifstream f("album.in");
- ofstream g("album.out");
- int i,j,k, ok,c1,c2,ct1,ct2,al=0,nrc;
- f>>c;
- if(c==1)
- {f>>n;
- for(i=1;i<=n;i++) f>>x;
- c1=-1; c2=-1;
- while(x!=0) {if(x%10>=c1) {c2=c1; c1=x%10;}
- else if(x%10>c2) c2=x%10;
- x=x/10;}
- g<<c2<<' '<<c1;
- }
- else
- { f>>n;
- for(i=1;i<=n;i++)
- {f>>x;
- y=x;
- nrc=0;
- while (y!=0) {nrc++;
- ci[nrc]=y%10;
- y=y/10;}
- do{ok=0;
- for(j=1;j<nrc;j++)
- if(ci[j]<ci[j+1]) {y=ci[j];
- ci[j]=ci[j+1];
- ci[j+1]=y;
- ok=1;}
- } while(ok==1);
- ok=0;
- c1=1000000;
- for(j=1;j<nrc;j++)
- for(k=j+1;k<=nrc;k++)
- {y=ci[j]*10+ci[k];
- if(ap[y]!=0) {ok=1;
- if(ap[y]<c1) {c1=ap[y];
- c2=y;}
- }
- }
- if(ok==0) {al++;
- ap[ci[1]*10+ci[2]]=al;
- if(al%2==1) v++;
- else r++;
- }
- else if(ap[c2]%2==1) v++;
- else r++;
- }
- if(v>r) g<<'V'<<'\n'<<v;
- else if(v==r) g<<'V'<<' '<<'R'<<'\n'<<v;
- else g<<'R'<<'\n'<<r;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement