Rating changes for last rounds are temporarily rolled back. They will be returned soon. ×

 
 
 
 
General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
191586108 Contestant:
Farhankhan
1778D - 35 C++17 (GCC 7-32) Wrong answer on test 24 483 ms 10860 KB 2023-02-01 18:42:58 2023-02-01 20:08:30
→ Source
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <ctype.h>
#include <queue>
#include <cstring>
#include <bitset>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <chrono>
#include <cassert>
#include <random>
#include <iomanip>
#include <stdio.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vpi;
typedef vector<vpi> vvpi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;

#define pu push
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define X first
#define Y second
#define forn(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repm(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define all(x) x.begin(),x.end()
#define si(x) int(x.size())
#define srt(c) sort(all(c))
#define srtrev(c) sort(all(c)); reverse(all(c))
#define read(x) scanf("%d", &x)
#define readv(x, n) vi x(n); forn(i,0,n) scanf("%d", &x[i])

ll gcd (ll a, ll b) {return b==0 ? a : gcd(b, a%b);}
const unsigned gen_seed = std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937_64 gen(gen_seed);

const int ZX = 33000;
const int long long mod = 1000000007;
const int MM = 998244353;
const int IINF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double DBINFI = numeric_limits<double>::infinity();
const double DBNAN = numeric_limits<double>::quiet_NaN();
const double EPS = 1e-9;
const double PI = acos((double)-1.0);
const int DX[] = { 1,  0, -1,  0,  1, -1,  1, -1};
const int DY[] = { 0,  1,  0, -1,  1, -1, -1,  1};
ll sqr(ll x) { return x*x; } ll sqr(int x) { return (ll)x*x; }
double sqr(double x) { return x*x; }
mt19937 mmtw(960172);
ll rnd(ll x, ll y) { static uniform_int_distribution<ll> d; return d(mmtw) % (y - x + 1) + x; }

template<typename T, typename U> static inline void amin(T &x, U y){ if(y<x) x=y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x<y) x=y; }
template<typename T> bool canPool(T const& g) { return g == T(0); }
bool canPool(float g) { return abs(g) < EPS; }
bool canPool(double g) { return abs(g) < EPS; }
bool canPool(long double g) { return abs(g) < EPS; }
bool compare(int a, int b) { return a>b; }
template<typename T> int sgn(T const& g) { if (canPool(g)) return 0; return g > 0 ? 1 : -1; }

#ifdef LOCAL
#define debug(...) debug_out(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) 2401
#endif

long long np, sp, xp, yp, inv[1000001];
string cp, dp;

int main() 
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  inv[0] = inv[1] = 1;
  for(ll i=2; i<= 1000000; ++i)
  {
	  inv[i] = 998244353 - 998244353 / i*inv[998244353%i]%998244353;
  }
  int t;
  cin>>t;
  while(t--)
  {
	  cin>>np>>cp>>dp;
	  sp=0;
	  xp=yp=1;
	  for(ll i=0; i<np; ++i)
	  {
		  sp+= cp[i] != dp[i];
	  }
	  for(ll i=np; i>=2; --i)
	  {
		  xp = ((np*inv[i]%998244353+(np*inv[i]%998244353-1)*xp%998244353)%998244353+998244353)%998244353;
		  yp = (yp+(i<=sp)*xp)%998244353;
	  }
	  if(sp==0)
	  {
		  cout<<0<<endl;
	  }
	  else
	  {
		  cout<<((xp*np+np+yp-xp)%998244353+998244353)%998244353-1<<endl;
	  }
  }
  return 0;
}
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details