Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- using namespace std;
- int ugyanaz(string a, string b)
- {
- int x = 0;
- int n = 0;
- while(a[n] == b[n])
- {
- x++;
- n++;
- }
- return x;
- }
- int main()
- {
- //BEOLVASÁS
- vector<int> szam;
- vector<string> azon;
- int n = 0;
- cin >> n;
- for(int i = 0; i < 200000; i++)
- {
- szam.push_back(i);
- azon.push_back(i);
- }
- //TÖMBÖK SORBARENDEZÉSE
- vector<int> sor;
- vector<string> kod;
- for(int i = 0; i<n; i++)
- {
- sor[i] = szam[i];
- kod[i] = azon[i];
- }
- int tmp =0;
- string s ="";
- for (int i = n-1; 0 < i; i--)
- {
- for (int j=0; j < i; j++)
- {
- if (sor[j]>sor[j+1])
- {
- tmp=sor[j];
- s=kod[j];
- sor[j]=sor[j+1];
- sor[j+1]=tmp;
- kod[j]=kod[j+1];
- kod[j+1]=s;
- }
- }
- }
- for (int i = n-1; 0 < i; i--)
- {
- for (int j=0; j < i; j++)
- {
- if (sor[j]==sor[j+1] && kod[j] >kod[j+1])
- {
- s=kod[j];
- kod[j]=kod[j+1];
- kod[j+1]=s;
- }
- }
- }
- //AZONOSÍTÓK ÖSSZEHASONLÍTÁSA
- vector<int> u;
- for(int i = 0; i <n; i++)
- {
- u[i] = 1;
- }
- for(int i = 0; i < n; i++)
- {
- for(int j = 0; j <n; j++)
- {
- if(sor[i] == sor[j] && i!= j)
- {
- if(ugyanaz(kod[i], kod[j]) + 1 > u[i])
- {
- u[i] = ugyanaz(kod[i], kod[j]) + 1;
- }
- }
- }
- }
- vector<int> x;
- for(int i = 0; i <n; i++)
- {
- for(int j = 0; j<n; j++)
- {
- if(szam[i] == sor[j] && azon[i] == kod[j])
- {
- x[i] = u[j];
- }
- }
- }
- for(int i = 0; i <n; i++)
- {
- cout << x[i] << endl;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement