結果
| 問題 | No.3587 Too Good to Swap |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-11-24 22:47:18 |
| 言語 | C++23(gcc16) (gcc 16.2.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 9 ms / 2,000 ms |
| + 439µs | |
| コード長 | 774 bytes |
| 記録 | |
| コンパイル時間 | 5,853 ms |
| コンパイル使用メモリ | 360,272 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-11-24 22:47:28 |
| 合計ジャッジ時間 | 6,146 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge5_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 49 |
ソースコード
#include <bits/stdc++.h>
#define All(x) x.begin(),x.end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
using ll=long long;
bool in_trapped_set(const string &s){
int n=s.size();
int last_g=-1;
int first_d=n;
for(int i=0;i<n;++i){
if(s[i]=='g') last_g=i;
if(s[i]=='d'&&first_d==n) first_d=i;
}
if(last_g==-1||first_d==n) return false;
return (first_d-last_g-1)>=3;
}
void solve(){
string s,t;
cin>>s>>t;
string ss=s,st=t;
sort(All(ss));
sort(All(st));
if(ss!=st){
cout<<"No\n";
return ;
}
cout<<(in_trapped_set(s)==in_trapped_set(t)?"Yes":"No")<<'\n';
}
signed main(){
IOS
int T;
cin>>T;
while(T--){
solve();
}
}