結果
| 問題 | No.3798 algo to goal |
| ユーザー |
|
| 提出日時 | 2026-11-13 23:00:24 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 37 ms / 2,000 ms |
| + 113µs | |
| コード長 | 1,294 bytes |
| 記録 | |
| コンパイル時間 | 2,323 ms |
| コンパイル使用メモリ | 344,372 KB |
| 実行使用メモリ | 6,460 KB |
| 最終ジャッジ日時 | 2026-11-13 23:00:31 |
| 合計ジャッジ時間 | 7,057 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge5_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 40 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int q;
cin >> q;
auto f = [&](string s){
array<int, 26> cnt0{}, cnt1{};
ll s0 = 0, s1 = 0;
for(int i = 0; i < (int)s.size(); i++){
int c = s[i] - 'a';
if(i % 2 == 0){
for(int j = c + 1; j < 26; j++) s0 += cnt0[j];
cnt0[c]++;
}else{
for(int j = c + 1; j < 26; j++) s1 += cnt1[j];
cnt1[c]++;
}
}
s0 &= 1, s1 &= 1;
for(int i = 0; i < 26; i++){
if(cnt0[i] >= 2) s0 |= 3;
}
for(int i = 0; i < 26; i++){
if(cnt1[i] >= 2) s1 |= 3;
}
return make_tuple(cnt0, cnt1, s0, s1);
};
while(q--){
string s, t;
cin >> s >> t;
if(s == t){
cout << "Yes\n";
continue;
}
auto [sC0, sC1, sS0, sS1] = f(s);
auto [tC0, tC1, tS0, tS1] = f(t);
if(sS0 == 3 || sS1 == 3){
cout << (sC0 == tC0 && sC1 == tC1 ? "Yes" : "No") << '\n';
}else{
cout << (sC0 == tC0 && sC1 == tC1 && ((sS0 ^ tS0) == (sS1 ^ tS1)) ? "Yes" : "No") << '\n';
}
}
}