Advertisement
Ankit_132

C

Sep 24th, 2023
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1.  
  2. #include <bits/stdc++.h>
  3.  
  4. using namespace std;
  5.  
  6. #define ll     long long
  7. #define _test   int _TEST; cin>>_TEST; while(_TEST--)
  8.  
  9. int main()
  10. {
  11.     ll int MOD = 998244353;
  12.     int N = 2e5 + 100;
  13.     vector<ll int> fact(N);
  14.     fact[0] = fact[1] = 1;
  15.     for(int i=2; i<N; i++)
  16.         (fact[i] = i*fact[i-1]) %= MOD;
  17.  
  18.     _test
  19.     {
  20.         string s;
  21.         cin>>s;
  22.  
  23.         int n = s.size();
  24.  
  25.         ll int cnt = 1;
  26.         ll int ans = 1;
  27.         int x = 1;
  28.  
  29.         char f = s[0];
  30.  
  31.         for(int i=1; i<n; i++)
  32.         {
  33.             if(f != s[i])
  34.             {
  35.                 (ans *= cnt) %= MOD;
  36.  
  37.                 x++;
  38.                 cnt = 1;
  39.             }
  40.             else
  41.                 cnt++;
  42.  
  43.             f = s[i];
  44.         }
  45.  
  46.         (ans *= cnt) %= MOD;
  47.         (ans *= fact[n-x]) %= MOD;
  48.  
  49.         cout<<n-x<<" "<<ans<<"\n";
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement