結果

問題 No.3798 algo to goal
ユーザー cho435
提出日時 2026-11-13 23:08:36
言語 C++23
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 70 ms / 2,000 ms
+ 205µs
コード長 1,179 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,457 ms
コンパイル使用メモリ 386,412 KB
実行使用メモリ 10,188 KB
最終ジャッジ日時 2026-11-13 23:08:51
合計ジャッジ時間 9,092 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using ll = long long;
#define rep(i, s, t) for (ll i = s; i < (ll)(t); i++)
#define all(x) begin(x), end(x)
template <class T> bool chmin(T& x, T y) {
	return x > y ? (x = y, true) : false;
}
template <class T> bool chmax(T& x, T y) {
	return x < y ? (x = y, true) : false;
}

int tnto(string s, string t) {
	{
		auto cs = s, ct = t;
		sort(all(cs));
		sort(all(ct));
		if (cs != ct) return -1;
	}
	int n = s.size();
	vector<int> idx(26, -1);
	rep(i, 0, n) {
		int c = t[i] - 'a';
		if (idx[c] != -1) return 2;
		idx[c] = i;
	}
	int res = 0;
	rep(i, 0, n) rep(j, 0, i) {
		if (idx[s[i] - 'a'] < idx[s[j] - 'a']) res++;
	}
	return res % 2;
}

void solve() {
	string s, t;
	cin >> s >> t;
	int n = s.size();
	vector<string> vs(2), vt(2);
	rep(i, 0, n) {
		vs[i & 1] += s[i];
		vt[i & 1] += t[i];
	}
	int t0 = tnto(vs[0], vt[0]);
	int t1 = tnto(vs[1], vt[1]);
	if (t0 == -1 || t1 == -1 || (t0 != t1 && t0 != 2 && t1 != 2))
		cout << "No\n";
	else cout << "Yes\n";
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(15);
	int t = 1;
	cin >> t;
	while (t--) solve();
}
0