Submission #3501462


Source Code Expand

#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define RREP(i,a,n) for(int i=n-1;i>=a;i--)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define all(a) (a).begin(),(a).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define sz(x) ((int)(x).size())
#define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define fs first
#define sc second

#define MOD 1000000007
#define INF 1LL<<55

#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)

using namespace std;

using ll = long long;

template<typename T1,typename T2> using P = pair< T1, T2 >;
using Pii = P<int,int>;
using Pll = P<ll,ll>;
using Pdd = P<double,double>;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<ll>;
using Vs = V<string>;

template<typename T1,typename T2> using M = map< T1, T2>;
using Mii = M<int, int>;
using Mll = M<ll, ll>;
using Msi = M<string, int>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

// please declaration dx[8], dy[8]
#define DX {-1,0,1,0,-1,-1,1,1}
#define DY {0,-1,0,1,-1,1,1,-1}
#define DX2 {-1,0,1,0}
#define DY2 {0,-1,0,1}

// 最大公約数
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
// 最大公倍数
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

// io 高速化
struct io{
    io(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}io;

signed main() {
  // s, t
  string s;
  string t;
  in(s);
  in(t);

  string wits;
  string witt;

  // resz(sz(s), wits);
  // resz(sz(s), witt);

  rep(i, sz(s)){
    if (s[i] != t[i]) {
      wits.pb(s[i]);
      witt.pb(t[i]);
    }
  }

  rep(i, sz(wits)){
    if (wits[i] != witt[i]) {
      char tmp = wits[i]; // z
      char nowt = witt[i]; // p
      wits[i] = witt[i]; // s <- t (z <- p)
      rep(j, sz(wits)) {
        if (j != i) {
          if (wits[j] == tmp) {
            wits[j] = witt[i];
          } else if (wits[j] == nowt) {
            wits[j] = tmp; // (p <- z)
          }
        }
      }
    }
  }
  // show(s, t);
  if (wits == witt) {
    out("Yes");
  } else {
    out("No");
  }

  return 0;
}

Submission Info

Submission Time
Task C - String Transformation
User mitubaEX
Language C++14 (GCC 5.4.1)
Score 0
Code Size 3485 Byte
Status WA
Exec Time 2107 ms
Memory 1428 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 3
AC × 19
WA × 2
TLE × 3
Set Name Test Cases
Sample sample_01, sample_02, sample_03
All 0_min0, 0_min1, 1_small0, 1_small1, 1_small2, 2_medium0, 2_medium1, 2_medium2, 2_medium3, 2_medium4, 3_max0, 3_max1, 3_max2, 3_max3, 3_max4, 3_max5, 3_max6, 3_max7, 3_max8, 3_max9, 5_hand0, sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
0_min0 AC 1 ms 256 KiB
0_min1 AC 1 ms 256 KiB
1_small0 AC 1 ms 256 KiB
1_small1 AC 1 ms 256 KiB
1_small2 AC 1 ms 256 KiB
2_medium0 TLE 2103 ms 1024 KiB
2_medium1 AC 7 ms 924 KiB
2_medium2 AC 3 ms 512 KiB
2_medium3 AC 11 ms 1152 KiB
2_medium4 AC 10 ms 1092 KiB
3_max0 TLE 2103 ms 1428 KiB
3_max1 AC 10 ms 1300 KiB
3_max2 TLE 2107 ms 1428 KiB
3_max3 WA 11 ms 1428 KiB
3_max4 AC 11 ms 1300 KiB
3_max5 WA 5 ms 916 KiB
3_max6 AC 7 ms 1428 KiB
3_max7 AC 10 ms 1428 KiB
3_max8 AC 10 ms 1428 KiB
3_max9 AC 10 ms 1428 KiB
5_hand0 AC 1 ms 256 KiB
sample_01 AC 1 ms 256 KiB
sample_02 AC 1 ms 256 KiB
sample_03 AC 1 ms 256 KiB