Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- int q,qinvers[12],p[10005],x[10005],n,k,cifre[10];
- int modif[10005], s[105],d[105];
- ifstream f("mostenire.in");
- ofstream g("mostenire.out");
- void cerinta1()
- {
- int i,j;
- for(i=1; i<=n; i++)
- f>>x[i];
- for(i=1; i<=k; i++)
- f>>s[i]>>d[i];
- for (i=k; i>=1; i--)
- {
- for(j=s[i]; j<=d[i]; j++)
- x[j]=qinvers[x[j]];
- }
- for(i=1; i<=n; i++)
- g<<x[i]<<" ";
- g<<endl;
- }
- void cerinta2()
- {
- int i,j, tmax=0,z=0,cif;
- for(i=1; i<=n; i++)
- f>>p[i];
- for(i=1; i<=k; i++)
- f>>s[i]>>d[i];
- for(i=1; i<=k; i++)
- for(j=s[i]; j<=d[i]; j++)
- modif[j]++;
- for(i=1; i<=n; i++)
- if(modif[i]>tmax)
- {
- tmax=modif[i];
- z=i;
- }
- cif=p[z];
- cifre[cif]=1;
- for(i=k; i>=1; i--)
- if( s[i]<=z && z<=d[i])
- {
- cif=qinvers[cif];
- cifre[cif]=1;
- }
- g<<z<<endl;
- for(i=1; i<=9; i++)
- if(cifre[i])g<<i<<" ";
- g<<endl;
- }
- int main()
- {
- int cer,i;
- f>>cer>>q>>n>>k;
- for(i=9; i>=1; i--)
- {
- qinvers[q%10]=i;
- q=q/10;
- }
- if(cer==1) cerinta1();
- else cerinta2();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement