結果
| 問題 | No.3798 algo to goal |
| ユーザー |
|
| 提出日時 | 2026-11-13 22:49:38 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
WA
不安定
|
| 実行時間 | - |
| コード長 | 6,137 bytes |
| 記録 | |
| コンパイル時間 | 4,279 ms |
| コンパイル使用メモリ | 366,424 KB |
| 実行使用メモリ | 42,628 KB |
| 最終ジャッジ日時 | 2026-11-13 22:49:49 |
| 合計ジャッジ時間 | 9,618 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge5_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 13 WA * 27 |
ソースコード
/*
#include<kyopro/master>
void self::main(){
multi_test_cases
auto s=sinen_alphabet();
auto t=sinen_alphabet();
vec<ll>se,so,te,to;
fo(i,0,s.size(),2)se.eb(s[i]);
fo(i,1,s.size(),2)so.eb(s[i]);
fo(i,0,t.size(),2)te.eb(t[i]);
fo(i,1,t.size(),2)to.eb(t[i]);
if(se.sort()!=te.sort())done(No());
if(so.sort()!=to.sort())done(No());
auto ok=[&](const vec<ll>&s,const vec<ll>&t){
if(s.size()!=s.unique().size())return true;
return false;
};
if(ok(se,te)&&ok(so,to))done(Yes());
ppYes((se.inversion(te)+so.inversion(to))%2==0);
}
*/
#include<bits/stdc++.h>
using namespace std;
namespace self{void main();void sub();void pp(auto&&...a);void ppe(auto&&...a);}
int main(){cin.tie(nullptr)->sync_with_stdio(0);cout<<fixed<<setprecision(15);self::main();}
#define eb emplace_back
#define done(...) return pp(__VA_ARGS__)
#define RD(T,...) T __VA_ARGS__;lin(__VA_ARGS__)
#define LL(...) RD(ll,__VA_ARGS__)
#define FO(n) for(ll IJK=n;IJK-->0;)
#define fo(i,...) for(auto[i,i##stop,i##step]=for_range<ll>(0,__VA_ARGS__);i<i##stop;i+=i##step)
#define of(i,...) for(auto[i,i##stop,i##step]=for_range<ll>(1,__VA_ARGS__);i>=i##stop;i+=i##step)
#define fe(a,e,...) for(auto&&__VA_OPT__([)e __VA_OPT__(,__VA_ARGS__]):a)
#define ef(a,e,...) for(auto&&__VA_OPT__([)e __VA_OPT__(,__VA_ARGS__]):ranges::reverse_view(a))
#define binary_operator(op,type) auto operator op(const type&rhs)const{auto copy=*this;return copy op##=rhs;}
#define multi_test_cases LL(T);FO(T)sub();}void self::sub(){
namespace self{
using ll=long long;
template<class T>constexpr auto for_range(T s,T b){T a=0;if(s)swap(a,b);return array{a-s,b,1-s*2};}
template<class T>constexpr auto for_range(T s,T a,T b,T c=1){return array{a-s,b,(1-s*2)*c};}
const string newline{char(10)};
void lin(auto&...a){(cin>>...>>a);}
auto encode_alphabet(char c){return c-'a';}
auto Yes(bool p=1){return p?"Yes":"No";}
auto No(){return Yes(0);}
void ppYes(bool p=1){cout<<Yes(p)<<newline;}
template<class A,class B=A>struct pair{
A a;B b;
pair()=default;
pair(A a,B b):a(a),b(b){}
auto operator<=>(const pair&)const=default;
};
template<class F=less<>>decltype(auto)sort(auto&&a,F f={}){ranges::sort(a,f);return a;}
decltype(auto)unique(auto&&a){sort(a).erase(ranges::unique(a).begin(),a.end());return a;}
template<class...A>using pack_back_t=tuple_element_t<sizeof...(A)-1,tuple<A...>>;
}
namespace self{
template<class T>class FenwickTree{
public:
ll n_;
vector<T>data_;
FenwickTree(ll n):n_(n),data_(n){}
void add(ll i,T x){
assert(0<=i&&i<n_);
i++;
while(i<=n_){
data_[i-1]+=x;
i+=i&-i;
}
}
T sum(ll l,ll r)const{
assert(0<=l&&l<=r&&r<=n_);
T res=0;
while(r>0)res+=data_[r-1],r-=r&-r;
while(l>0)res-=data_[l-1],l-=l&-l;
return res;
}
};
}
namespace self{
template<class V>concept vectorial=is_base_of_v<vector<typename remove_cvref_t<V>::value_type>,remove_cvref_t<V>>;
template<class T>struct core_t_helper{using type=T;};
template<class T>using core_t=core_t_helper<T>::type;
template<class V>struct vec;
template<int D,class T>struct hvec_helper{using type=vec<typename hvec_helper<D-1,T>::type>;};
template<class T>struct hvec_helper<0,T>{using type=T;};
template<int D,class T>using hvec=hvec_helper<D,T>::type;
template<class V>struct vec:vector<V>{
using C=core_t<V>;
using vector<V>::vector;
auto&operator^=(const vec&u){this->insert(this->end(),u.begin(),u.end());return*this;}
binary_operator(^,vec)
ll size()const{return vector<V>::size();}
auto&emplace_back(auto&&...a){vector<V>::emplace_back(std::forward<decltype(a)>(a)...);return*this;}
auto pop_back(){auto r=this->back();vector<V>::pop_back();return r;}
template<class F>void for_each_core(F&&f)const{fe(*this,e){if constexpr(vectorial<V>){ }else f(e);}}
template<class T=C>auto fold(auto&&f)const{
pair<T,bool>res{};
for_each_core([&](const C&e){
if(res.b)f(res.a,e);
else res={e,1};
});
return res;
}
auto max()const{return fold([](auto&a,auto b){if(a<b)a=b;}).a;}
template<class F=less<>>vec sort(F f={})const{vec v=*this;ranges::sort(v,f);return v;}
template<class F=less<>>vec stable_sort(F f={})const{vec v=*this;ranges::stable_sort(v,f);return v;}
template<class F=less<>>auto sort_from(F f={})const{
vec<ll>o(size());
std::iota(o.begin(),o.end(),0);
return o.stable_sort([&](ll i,ll j){return f((*this)[i],(*this)[j]);});
}
template<class F=less<>>auto zip(F f={})const{
auto o=sort_from(f);
vec<ll>res(size());
ll c=0;
fo(i,1,size()){
if(f((*this)[o[i-1]],(*this)[o[i]]))c++;
res[o[i]]=c;
}
return res;
}
auto matching_order(const vec&b)const{
assert(sort()==b.sort());
ll n=size();
auto z=(*this^b).zip();
vec<vec<ll>>g(z.max()+1);
vec<ll>res(size());
of(i,n)g[z[i+n]].eb(i);
fo(i,n)res[i]=g[z[i]].pop_back();
return res;
}
auto flatten()const{if constexpr(!vectorial<V>)return*this;else{ }}
auto unique()const{auto res=flatten();return self::unique(res);}
ll inversion()const{
ll res=0;
FenwickTree<ll>s(size());
ef(sort_from(),i){
res+=s.sum(0,i);
s.add(i,1);
}
return res;
}
ll inversion(const vec&v)const{return matching_order(v).inversion();}
};
template<class...A>requires(sizeof...(A)>=2)vec(const A&...a)->vec<hvec<sizeof...(A)-2,pack_back_t<A...>>>;
auto sin(){string s;lin(s);return s;}
template<class T=ll>auto sinen_alphabet(){vec<T>r;fe(sin(),e)r.eb(encode_alphabet(e));return r;}
}
void self::pp(auto&&...a){const char*c="";((cout<<c<<a,c=" "),...);cout<<'\n';}
void self::main(){
multi_test_cases
auto s=sinen_alphabet();
auto t=sinen_alphabet();
vec<ll>se,so,te,to;
fo(i,0,s.size(),2)se.eb(s[i]);
fo(i,1,s.size(),2)so.eb(s[i]);
fo(i,0,t.size(),2)te.eb(t[i]);
fo(i,1,t.size(),2)to.eb(t[i]);
if(se.sort()!=te.sort())done(No());
if(so.sort()!=to.sort())done(No());
auto ok=[&](const vec<ll>&s,const vec<ll>&t){
if(s.size()!=s.unique().size())return true;
return false;
};
if(ok(se,te)&&ok(so,to))done(Yes());
ppYes((se.inversion(te)+so.inversion(to))%2==0);
}