fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll int
  4. #define nhanh ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
  5. #define nmax 1000007
  6. #define fi first
  7. #define se second
  8. #define pll pair<ll,ll>
  9. const ll mod = 1e9+7;
  10. ll n,k,x,y,z,dp[10],cnt[10],ans = 0;
  11. void lis(ll x)
  12. {
  13.  
  14. vector<ll> vt;
  15. while (x > 0)
  16. {
  17. vt.push_back(x % 10);
  18. x/=10;
  19. }
  20. reverse(vt.begin(),vt.end());
  21.  
  22. memset(dp,0x3f,sizeof(dp));
  23.  
  24. for (int i = 0; i < vt.size(); i++)
  25. {
  26. ll p = lower_bound(vt.begin(),vt.end(), vt[i]) - vt.begin();
  27. if (p == vt.size()) continue;
  28. dp[p] = vt[i];
  29.  
  30. ans = max(ans, p + 1);
  31. cnt[p + 1]++;
  32. }
  33.  
  34.  
  35. }
  36. void sol(ll x,ll y)
  37. {
  38. for (int i = x; i <= y; i++)
  39. {
  40. lis(i);
  41. }
  42. cout <<ans <<" "<<cnt[ans]<<"\n";
  43. memset(cnt,0,sizeof(cnt));
  44. ans = 0;
  45.  
  46. }
  47. int main()
  48. {
  49. freopen("LISX.INP","r",stdin);
  50. freopen("LISX.OUT","w",stdout);
  51. nhanh
  52. cin >> n;
  53. while (n--)
  54. {
  55. cin >> x >> y;
  56. sol(x, y);
  57. }
  58. }
  59.  
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
Standard output is empty