結果
問題 | No.1192 半部分列 |
ユーザー |
|
提出日時 | 2020-08-05 15:07:26 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,280 bytes |
コンパイル時間 | 2,220 ms |
コンパイル使用メモリ | 201,956 KB |
最終ジャッジ日時 | 2025-01-12 14:55:02 |
ジャッジサーバーID (参考情報) |
judge4 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 WA * 14 RE * 1 |
ソースコード
#include<bits/stdc++.h> using namespace std; #define int long long #define rep(i,n) for(int i=0;i<n;i++) #define REP(i,n) for(int i=1;i<n;i++) #define rev(i,n) for(int i=n-1;i>=0;i--) #define all(v) v.begin(),v.end() #define P pair<int,int> #define len(s) (int)s.size() template<class T> inline bool chmin(T &a, T b){ if(a>b){a=b;return true;} return false; } template<class T> inline bool chmax(T &a, T b){ if(a<b){a=b;return true;} return false; } constexpr int mod = 1e9+7; constexpr int inf = 3e18; string S,T; void solvesmall(){ set<string>setS,setT; rep(i,1<<len(S)){ string now; rep(j,len(S)){ if(i>>j&1)now+=S[j]; } setS.insert(now); } rep(i,1<<len(T)){ string now; rep(j,len(T)){ if(i>>j&1)now+=T[j]; } setT.insert(now); } for(string s:setS){ if(setT.find(s)==setT.end()){ cout<<s<<endl;return; } } cout<<"-1"<<endl; } signed main(){ cin>>S>>T; assert(len(S)<=100000&&len(T)<=100000); if(len(S)<=18&&len(T)<=18)solvesmall(); else { int cnt1=0,cnt2=0; rep(i,len(S))cnt1+=S[i]=='a'; rep(i,len(T))cnt2+=S[i]=='a'; if(cnt1<=cnt2){ cout<<"-1"<<endl; }else { rep(i,cnt2+1)cout<<'a'; cout<<endl; } } }