QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#227334 | #7618. Pattern Search | Giga_Cronos# | WA | 0ms | 3828kb | C++14 | 2.4kb | 2023-10-27 12:28:18 | 2023-10-27 12:28:19 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
/// MACROS
#define int long long
#define itn int
#define str string
#define sz size
#define ll long long
#define ull unsigned long long
#define ld long double
#define ii pair<int, int>
#define fs first
#define sc second
#define vi vector<int>
#define vii vector<ii>
#define pb push_back
#define pf push_front
#define fl '\n'
#define el endl
#define eps 1e-12
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define SORT(x) sort(all(x))
#define RSORT(x) sort(rall(x))
#define REV(x) reverse(all(x))
/// FUNCTIONS
const int maxn=100005;
const int maxm=100005;
#define db(x) cerr << #x << ": " << (x) << '\n';
#define lg2(x) __lg(x)
#define pi acos(-1)
#define YN(x) cout << ((x) ? ("YES") : ("NO")) << fl;
#define yn(x) cout << ((x) ? ("Yes") : ("No")) << fl;
#define precision(x) cout.setf(ios::fixed);cout.precision(x);
void print(const auto &v){for(auto it: v)cout<<it<<" ";cout<<fl;}
void printp(const auto &v){for(auto it: v)cout<<it.fs<<" "<<it.sc<<fl;}
vi read(int cnt){vi v(cnt);for(int i=0;i<cnt;i++)cin>>v[i];return v;}
vii readp(int cnt){vii v(cnt);for(int i=0;i<cnt;i++)cin>>v[i].fs>>v[i].sc;return v;}
/////////////////////////////////////////////////////////////////////////////////////
int s[300];
int t[300];
void solve(){
str ss,tt;
cin>>ss>>tt;
for(int i=0;i<300;i++){
s[i]=t[i]=0;
}
for(auto it:ss){
s[it]++;
}
for(auto it:tt){
t[it]++;
}
for(int i='a';i<='z';i++){
if(s[i]<t[i]){
cout<<0<<fl;
return;
}
}
int ans=0;
for(int k=1;k<=tt.sz();k++){
int sol=1e9;
bool can=true;
for(int i='a';i<='z';i++){
int p=t[i]/k;
int r=t[i]%k;
int d=p-r;
int q=d/(k+1);
p=p-q;
r=t[i]-p*k;
if(p==0){if(t[i])can=false;continue;}
// cout<<k<< " "<<(char)i<<" "<<p<<" "<<r<<fl;
sol=min(sol, 1+ (s[i]-t[i])/p );
}
// cout<<k<<" "<<sol<<fl;
if(sol!=1e9 && can)ans=max(ans,sol);
}
cout<<ans<<fl;
}
int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(0);
int tc=1;
cin>>tc;
while(tc--){
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3532kb
input:
2 bajkaaall aal abca cba
output:
2 1
result:
ok 2 number(s): "2 1"
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3828kb
input:
16 a a a b b a aa a ab aa ab b ab c aaz az abcde edcba aaaaaaaaaaaabbb aaaaaaaaabb aaaaaazz az aaaaaaaaaz zzzzz gggggggggggggggggggge ggggeeee hyphyphyphyphyphyphyphyphyphyphyphyp eeeeeeeeee hyphyphyphyphyphyphyphyphyphyphyphype eeteeteeteet aaaabbbbbbcccccccc aaabbbbbcccccc
output:
1 0 0 2 0 1 0 1 1 2 2 0 0 0 0 2
result:
wrong answer 16th numbers differ - expected: '1', found: '2'