結果
| 問題 | No.3798 algo to goal |
| ユーザー |
kwm_t
|
| 提出日時 | 2026-11-13 23:21:26 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
WA
不安定
|
| 実行時間 | - |
| コード長 | 2,291 bytes |
| 記録 | |
| コンパイル時間 | 2,978 ms |
| コンパイル使用メモリ | 346,328 KB |
| 実行使用メモリ | 10,508 KB |
| 最終ジャッジ日時 | 2026-11-13 23:21:38 |
| 合計ジャッジ時間 | 10,523 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 10 WA * 30 |
ソースコード
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
// using namespace atcoder;
// using mint = modint1000000007;
// const int mod = 1000000007;
// using mint = modint998244353;
// const int mod = 998244353;
// const int INF = 1e9;
// const long long LINF = 1e18;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, l, r) for (int i = (l); i < (r); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rrep2(i, l, r) for (int i = (r)-1; i >= (l); --i)
#define all(x) (x).begin(), (x).end()
#define allR(x) (x).rbegin(), (x).rend()
#define P pair<int, int>
template<typename A, typename B> inline bool chmax(A& a, const B& b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A& a, const B& b) { if (a > b) { a = b; return true; } return false; }
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int t; cin >> t;
while (t--) {
auto chk = [&](string s, string t) {
string s0, s1, t0, t1;
rep(i, s.size()) {
if (i % 2 == 0)s0 += s[i];
else s1 += s[i];
}
rep(i, t.size()) {
if (i % 2 == 0)t0 += t[i];
else t1 += t[i];
}
sort(all(s0));
sort(all(s1));
sort(all(t0));
sort(all(t1));
return s0 == t0 && s1 == t1;
};
string s, t; cin >> s >> t;
if (!chk(s, t)) {
cout << "No" << endl;
continue;
}
auto chk1 = [&](string s) {
vector<int>c0(26), c1(26);
rep(i, s.size()) {
if (i % 2 == 0)c0[s[i] - 'a']++;
else c1[s[i] - 'a']++;
}
rep(i, 26)if (c0[i] > 1)return true;
rep(i, 26)if (c1[i] > 1)return true;
return false;
};
if (chk1(s) || chk1(t)) {
cout << "Yes" << endl;
continue;
}
auto chk2 = [&](string s)->P {
vector<int>c0(26), c1(26);
int x0 = 0, x1 = 0;
rep(i, s.size()) {
if (i % 2 == 0) {
rep2(j, s[i] - 'a', 26)x0 += c0[j];
c0[s[i] - 'a']++;
}
else {
rep2(j, s[i] - 'a', 26)x1 += c1[j];
c1[s[i] - 'a']++;
}
//rep(j, 26)cout << c0[j];
//cout << endl;
//rep(j, 26)cout << c1[j];
//cout << endl;
x0 %= 2;
x1 %= 2;
}
//cout << x0 << "_" << x1 << endl;
return { x0,x1 };
};
auto p0 = chk2(s);
if (p0.first == p0.second)cout << "Yes" << endl;
else cout << "No" << endl;
}
return 0;
}
kwm_t