結果
| 問題 | No.3798 algo to goal |
| ユーザー |
|
| 提出日時 | 2026-11-13 23:08:36 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 70 ms / 2,000 ms |
| + 205µs | |
| コード長 | 1,179 bytes |
| 記録 | |
| コンパイル時間 | 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 |
ソースコード
#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();
}