結果

問題 No.2209 Flip and Reverse
ユーザー Ujjwal RanaUjjwal Rana
提出日時 2023-02-10 21:29:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 2,675 bytes
コンパイル時間 4,044 ms
コンパイル使用メモリ 248,704 KB
実行使用メモリ 5,680 KB
最終ジャッジ日時 2023-09-21 22:33:05
合計ジャッジ時間 6,001 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 6 ms
5,488 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 7 ms
5,448 KB
testcase_15 AC 8 ms
5,424 KB
testcase_16 AC 8 ms
5,420 KB
testcase_17 AC 7 ms
5,496 KB
testcase_18 AC 6 ms
5,504 KB
testcase_19 AC 7 ms
5,432 KB
testcase_20 AC 8 ms
5,680 KB
testcase_21 AC 8 ms
5,504 KB
testcase_22 AC 8 ms
5,364 KB
testcase_23 AC 7 ms
5,444 KB
testcase_24 AC 6 ms
5,516 KB
testcase_25 AC 8 ms
5,508 KB
testcase_26 AC 6 ms
5,504 KB
testcase_27 AC 6 ms
5,428 KB
testcase_28 AC 7 ms
5,440 KB
testcase_29 AC 7 ms
5,432 KB
testcase_30 AC 6 ms
5,368 KB
testcase_31 AC 8 ms
5,488 KB
testcase_32 AC 7 ms
5,440 KB
testcase_33 AC 7 ms
5,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target ("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 

#define endl '\n'
typedef long long ll;
#define mod1 (ll)1000000007
#define mod2 (ll)998244353
#define pll pair<ll,ll>
typedef long double lb;
typedef tree<
pair<ll, ll>,
null_type,
less<pair<ll, ll>>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
#define eps (lb)(1e-9)
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// Operator overloads
template<typename T1, typename T2> // cin >> pair<T1, T2>
istream& operator>>(istream &istream, pair<T1, T2> &p) { return (istream >> p.first >> p.second); }

template<typename T> // cin >> vector<T>
istream& operator>>(istream &istream, vector<T> &v)
{
    for (auto &it : v)
        cin >> it;
    return istream;
}

template<typename T1, typename T2> // cout << pair<T1, T2>
ostream& operator<<(ostream &ostream, const pair<T1, T2> &p) { return (ostream << p.first << " " << p.second); }
template<typename T> // cout << vector<T>
ostream& operator<<(ostream &ostream, const vector<T> &c) { for (auto &it : c) cout << it << " "; return ostream; }

// Utility functions
template <typename T>
void print(T &&t)  { cout << t << "\n"; }
template <typename T, typename... Args>
void print(T &&t, Args &&... args)
{
    cout << t << " ";
    print(forward<Args>(args)...);
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll random(ll p){ // gives random number in [0,p]

 return uniform_int_distribution<ll>(0, p)(rng);
}
ll solve();
int main() {
io;
ll t=1,n=1;
// cin>>t;
while (t--){
     cout<<solve()<<endl;;
    }
     return 0;
}
ll solve(){
     ll n;
     string s,t;
    cin>>n>>s>>t;
    if(s==t){return 0;}
    ll ans=0;
    for(int i(0);i<n;++i){
        ans+=(s[i]!=t[i]);
    }
    if((ans%2)==0){return ans;}
    reverse(begin(s),end(s));
    ans=0;
    for(int i(0);i<n;++i){
        ans+=(s[i]!=t[i]);
    }
    return ans;



}
// Do not get stuck on a single approach for long, think of multiple ways
0