Submission #64299881


Source Code Expand

//#pragma GCC target("avx2")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define DEBUG
#ifdef DEBUG
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << '(' << p.first << ',' << p.second << ')';
    return os;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << '{';
    for(int i = 0; i < (int)v.size(); i++) {
        if(i) { os << ','; }
        os << v[i];
    }
    os << '}';
    return os;
}
void debugg() { cerr << endl; }
template <class T, class... Args>
void debugg(const T &x, const Args &... args) {
    cerr << " " << x;
    debugg(args...);
}
#define debug(...)                                                             \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]: ", debugg(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T a){
    int sz = a.size();
    for(auto itr = a.begin(); itr != a.end(); itr++){
		cout << *itr;
        sz--;
        if(sz) cout << " ";
	}
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){
	cout << a << " " << b << "\n";
}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
void mark() {cout << "#" << "\n";}
ll pcount(ll x) {return __builtin_popcountll(x);}
//#include <atcoder/convolution>
//#include <atcoder/modint>
//#include <atcoder/segtree>
// #include <atcoder/modint.hpp>
//#include <atcoder/lazysegtree>
//#include <atcoder/string>
//using namespace atcoder;
const int inf = (1<<30)-1;
const ll linf = 1LL<<61;
const int MAX = 510000;
int dy[8] = {0,1,0,-1,1,-1,-1,1};
int dx[8] = {-1,0,1,0,1,-1,1,-1};
// int dy[4] = {0,1,0,-1};
// int dx[4] = {1,0,-1,0};
// int dx[6] = {0,1,0,-1,-1,1};
// int dy[6] = {1,0,-1,-1,0,1};
const double pi = acos(-1);
const long double eps = 1e-11;
//const int mod = 1e9 + 7;
const int mod = 998244353;

template <int mod> struct ModInt {
    int x;

    ModInt() : x(0) {}

    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    ModInt &operator+=(const ModInt &p) {
        if((x += p.x) >= mod) x -= mod;
        return *this;
    }

    ModInt &operator-=(const ModInt &p) {
        if((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }

    ModInt &operator*=(const ModInt &p) {
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }

    ModInt &operator/=(const ModInt &p) {
        *this *= p.inverse();
        return *this;
    }

    ModInt operator-() const { return ModInt(-x); }

    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

    bool operator==(const ModInt &p) const { return x == p.x; }

    bool operator!=(const ModInt &p) const { return x != p.x; }

    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }

    ModInt pow(int64_t n) const {
        ModInt ret(1), mul(x);
        while(n > 0) {
            if(n & 1) ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }

    friend ostream &operator<<(ostream &os, const ModInt &p) {
        return os << p.x;
    }

    friend istream &operator>>(istream &is, ModInt &a) {
        int64_t t;
        is >> t;
        a = ModInt<mod>(t);
        return (is);
    }

    static int get_mod() { return mod; }
};

using mint = ModInt<mod>;

template< typename Monoid >
struct SegmentTree {
  using F = function< Monoid(Monoid, Monoid) >;

  int sz;
  vector< Monoid > seg;

  const F f = [](int a, int b){return max(a,b);};
  const Monoid M1;

  SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz, M1);
  }

  void set(int k, const Monoid &x) {
    seg[k + sz] = x;
  }

  void build() {
    for(int k = sz - 1; k > 0; k--) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  void update(int k, const Monoid &x) {
    k += sz;
    seg[k] = x;
    while(k >>= 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  Monoid query(int a, int b) {
    Monoid L = M1, R = M1;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) L = f(L, seg[a++]);
      if(b & 1) R = f(seg[--b], R);
    }
    return f(L, R);
  }

  Monoid operator[](const int &k) const {
    return seg[k + sz];
  }

  template< typename C >
  int find_subtree(int a, const C &check, Monoid &M, bool type) {
    while(a < sz) {
      Monoid nxt = type ? f(seg[2 * a + type], M) : f(M, seg[2 * a + type]);
      if(check(nxt)) a = 2 * a + type;
      else M = nxt, a = 2 * a + 1 - type;
    }
    return a - sz;
  }


  template< typename C >
  int find_first(int a, const C &check) {
    Monoid L = M1;
    if(a <= 0) {
      if(check(f(L, seg[1]))) return find_subtree(1, check, L, false);
      return -1;
    }
    int b = sz;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) {
        Monoid nxt = f(L, seg[a]);
        if(check(nxt)) return find_subtree(a, check, L, false);
        L = nxt;
        ++a;
      }
    }
    return -1;
  }

  template< typename C >
  int find_last(int b, const C &check) {
    Monoid R = M1;
    if(b >= sz) {
      if(check(f(seg[1], R))) return find_subtree(1, check, R, true);
      return -1;
    }
    int a = sz;
    for(b += sz; a < b; a >>= 1, b >>= 1) {
      if(b & 1) {
        Monoid nxt = f(seg[--b], R);
        if(check(nxt)) return find_subtree(b, check, R, true);
        R = nxt;
      }
    }
    return -1;
  }
};


vector<mint> fac(MAX), finv(MAX), inv(MAX);

void comInit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(ll i=2; i<MAX; i++){
        fac[i] = fac[i-1]*i;
        inv[i] = -inv[mod%i] * (mod/i);
        finv[i] = finv[i-1] * inv[i];
    }
}

mint com(ll n, ll k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] * finv[n-k];
}

template <typename T> struct Compress{
	vector<T> comp;

	Compress(vector<T> v) : comp(v){
		sort(comp.begin(), comp.end());
		comp.erase(unique(comp.begin(), comp.end()), comp.end());
	}

	ll get(T x){
		return lower_bound(comp.begin(), comp.end(), x) - comp.begin();
	}

	bool contain(T x){
		return binary_search(comp.begin(), comp.end(), x);
	}

	T operator[](int id){
		return comp[id];
	}

	ll siz(){
		return comp.size();
	}
};

vl divisor(ll n){
  vl res;
  for(ll i=1; i*i<=n; i++){
    if(n % i == 0){
      res.push_back(i);
      if(n / i != i) res.push_back(n/i);
    }
  }
  sort(all(res));
  return res;
}

struct Dinic{
	struct edge{
		ll to, cap, rev;
	};
	vector<vector<edge>> G;
	vector<int> level, itr;
	ll n;
	const ll INF = 1<<30;
 
	Dinic(ll n) : n(n){
		G.resize(n);
		level.resize(n);
		itr.resize(n);
	}
 
	void add_edge(ll from, ll to, ll cap){
		G[from].push_back({to,cap,(ll)G[to].size()});
		G[to].push_back({from,0,(ll)G[from].size()-1});
	}
 
	void bfs(int s){
		fill(level.begin(), level.end(), -1);
		queue<int> q;
		level[s] = 0;
		q.push(s);
		while(!q.empty()){
			int u = q.front(); q.pop();
			for(auto &e : G[u]){
				if(e.cap > 0 && level[e.to] < 0){
					level[e.to] = level[u] + 1;
					q.push(e.to);
				}
			}
		}
	}

	ll dfs(int u, int t, ll f){
		if(u == t) return f;
		for(int &i = itr[u]; i < G[u].size(); i++){
			edge &e = G[u][i];
			if(e.cap > 0 && level[u] < level[e.to]){
				ll d = dfs(e.to, t, min(f, e.cap));
				if(d > 0){
					e.cap -= d;
					G[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}
 
	ll max_flow(ll s, ll t){
		ll flow = 0;
		while(1){
			bfs(s);
			if(level[t] < 0) return flow;
			fill(itr.begin(), itr.end(), 0);
			ll f;
			while((f = dfs(s, t, INF)) > 0){
				flow += f;
			}
		}
	}
};

struct UnionFind{
	vl p;
	vl rank;
	vl cnt;

	UnionFind(ll n){
		rank.resize(n,0);
		p.resize(n,0);
		cnt.resize(n,0);
		rep(i,n){
			p[i] = i;
			rank[i] = 0;
			cnt[i] = 1;
		}
	}

	ll find(ll x){
		if(x != p[x]) p[x] = find(p[x]);
		return p[x];
	}

	bool same(ll x, ll y){
		return find(x) == find(y);
	}

	void unite(ll x, ll y){
		x = find(x);
		y = find(y);
		if(x == y) return;
		if(x < y){
			p[y] = x;
			cnt[x] += cnt[y];
		}else{
			p[x] = y;
			cnt[y] += cnt[x];
		}
	}

	ll size(ll x){
		return cnt[find(x)];
	}
};

struct scc{
    vector<vector<ll>> g,rg,li;
    vector<int> cmp,ord,vis;
    int sz = 0;

    scc(int n) : g(n), rg(n) {}
    scc(vector<vector<ll>> g) : g(g), rg(g.size()){
        rep(i,g.size()) for(auto v : g[i]) rg[v].push_back(i);
    }

    void add_edge(int u, int v){
        g[u].push_back(v);
        rg[v].push_back(u);
    }

    void dfs(int u){
        if(vis[u]) return;
        vis[u] = true;
        for(auto v : g[u]) dfs(v);
        ord.push_back(u);
    }

    void rdfs(int u, int now){
        if(cmp[u] != -1) return;
        cmp[u] = now;
        for(auto v : rg[u]) rdfs(v,now);
    }

    int build(vector<vector<ll>> &h){
        cmp.resize(g.size(),-1);
        vis.resize(g.size(),false);
        rep(i,g.size()) dfs(i);
        reverse(ord.begin(),ord.end());
        for(auto s : ord) if(cmp[s] == -1) rdfs(s,sz++);
        h.resize(sz);
        li.resize(sz);
        rep(i,g.size()){
            for(auto v : g[i]){
                if(cmp[i] != cmp[v]) h[cmp[i]].push_back(cmp[v]);
            }
        }
        rep(i,h.size()){
            sort(all(h[i])); h[i].erase(unique(all(h[i])), h[i].end());
        }
        rep(i,g.size()) li[cmp[i]].push_back(i);

        return sz;
    }

    int operator[](int x) const {
        return cmp[x];
    }
};

template<class Abel> struct WeightUnionFind {
	vector<int> par;
	vector<int> rank;
	vector<Abel> diff_weight;

	WeightUnionFind(int n = 1, Abel SUM_UNITY = 0) {
		init(n, SUM_UNITY);
	}

	void init(int n = 1, Abel SUM_UNITY = 0) {
		par.resize(n); rank.resize(n); diff_weight.resize(n);
		for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
	}

	int root(int x) {
		if (par[x] == x) {
			return x;
		}
		else {
			int r = root(par[x]);
			diff_weight[x] += diff_weight[par[x]];
			return par[x] = r;
		}
	}

	Abel weight(int x) {
		root(x);
		return diff_weight[x];
	}

	bool issame(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y, Abel w) {
		w += weight(x); w -= weight(y);
		x = root(x); y = root(y);
		if (x == y) return w == 0;
		if (rank[x] < rank[y]) swap(x, y), w = -w;
		if (rank[x] == rank[y]) ++rank[x];
		par[y] = x;
		diff_weight[y] = w;
		return true;
	}

	Abel diff(int x, int y) {
		return weight(y) - weight(x);
	}
};

template<typename T> struct BIT{
	vector<T> dat;
	ll sz;
	//all 1-indexed
	BIT(ll sz) : sz(sz){
		dat.assign(++sz, 0);
	}

	T sum(ll k){
		T ret = 0;
		for(++k; k > 0; k -= k & -k) ret += dat[k];
		return (ret);
	}

	void add(ll k, T x){
		for(++k; k < dat.size(); k += k & -k) dat[k] += x;
	}
	
	ll get(T k){
		if(k <= 0) return 0; 
		ll ret = 0;
		int n = 1; while(n < sz) n *= 2;
		for(int i=n/2; i>0; i/=2){
			if(ret+i < sz && dat[ret+i] < k){
				k -= dat[ret+i];
				ret += i;
			}
		}
		return ret;
	}
};

int main(){
  int n; cin >> n;
  string s,t; cin >> s >> t;
  int ans = 0;
  rep(i,n) ans += (s[i] != t[i]);
  cout << ans << endl;
}

Submission Info

Submission Time
Task A - Hamming Distance
User suta
Language C++ 23 (gcc 12.2)
Score 100
Code Size 12991 Byte
Status AC
Exec Time 4 ms
Memory 9068 KiB

Compile Error

Main.cpp: In member function ‘ll Dinic::dfs(int, int, ll)’:
Main.cpp:369:40: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<Dinic::edge>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
  369 |                 for(int &i = itr[u]; i < G[u].size(); i++){
      |                                      ~~^~~~~~~~~~~~~
Main.cpp: In constructor ‘scc::scc(std::vector<std::vector<long long int> >)’:
Main.cpp:47:32: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<std::vector<long long int> >::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   47 | #define rep(i,n) for(int i=0; i<(n); i++)
      |                                ^
Main.cpp:447:9: note: in expansion of macro ‘rep’
  447 |         rep(i,g.size()) for(auto v : g[i]) rg[v].push_back(i);
      |         ^~~
Main.cpp: In member function ‘int scc::build(std::vector<std::vector<long long int> >&)’:
Main.cpp:47:32: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<std::vector<long long int> >::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   47 | #define rep(i,n) for(int i=0; i<(n); i++)
      |                                ^
Main.cpp:471:9: note: in expansion of macro ‘rep’
  471 |         rep(i,g.size()) dfs(i);
      |         ^~~
Main.cpp:47:32: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<std::vector<long long int> >::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   47 | #define rep(i,n) for(int i=0; i<(n); i++)
      |                                ^
Main.cpp:476:9: note: in expansion of macro ‘rep’
  476 |         rep(i,g.size()){
      |         ^~~
Main.cpp:47:32: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<std::vector<long long int> >::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   47 | #define rep(i,n) for(int i=0; i<(n); i++)
      |                                ^
Main.cpp:481:9: note: in expansion of macro ‘rep’
  481 |         rep(i,h.size()){
      |         ^~~
Main.cpp:47:32: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<std::vector<long long int> >::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   47 | #define rep(i,n) for(int i=0; i<(n); i++)
      |                                ^
Main.cpp:484:9: note: in expansion of macro ‘rep’
  484 |         rep(i,g.size()) li[cmp[i]].push_back(i);
      |         ^~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 4
AC × 17
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 02_random2_00.txt, 02_random2_01.txt, 02_random2_02.txt, 02_random2_03.txt, 02_random2_04.txt, 02_random2_05.txt, 02_random2_06.txt, 02_random2_07.txt, 03_handmade_00.txt, 03_handmade_01.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 4 ms 8916 KiB
00_sample_01.txt AC 3 ms 8912 KiB
00_sample_02.txt AC 4 ms 8976 KiB
00_sample_03.txt AC 3 ms 9036 KiB
01_random_00.txt AC 4 ms 9052 KiB
01_random_01.txt AC 3 ms 9068 KiB
01_random_02.txt AC 3 ms 8956 KiB
02_random2_00.txt AC 4 ms 8976 KiB
02_random2_01.txt AC 4 ms 8908 KiB
02_random2_02.txt AC 3 ms 9056 KiB
02_random2_03.txt AC 4 ms 9044 KiB
02_random2_04.txt AC 3 ms 8960 KiB
02_random2_05.txt AC 3 ms 8956 KiB
02_random2_06.txt AC 3 ms 8956 KiB
02_random2_07.txt AC 4 ms 9004 KiB
03_handmade_00.txt AC 3 ms 8956 KiB
03_handmade_01.txt AC 3 ms 8936 KiB