QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#459852#7618. Pattern SearchmanizareWA 1ms7780kbC++141.5kb2024-06-30 15:05:362024-06-30 15:05:36

Judging History

你现在查看的是最新测评结果

  • [2024-06-30 15:05:36]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:7780kb
  • [2024-06-30 15:05:36]
  • 提交

answer

#include <bits/stdc++.h>
 

#pragma GCC optimize("O3,unroll-loops")
#define pb push_back
#define F first
#define S second 
#define all(a) a.begin(),a.end()
#define pii pair <int,int>
#define PII pair<pii , pii>
#define ld long double
#define int long long 
#define sz(v) (int)v.size()
#define rep(i , a , b) for(int i=a;i <= b;i++)
#define per(i, a , b) for(int i=a;i >= b;i--)
using namespace std ;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int maxn = 5e5 + 210, maxq = 1e5 ,  N = 1e5 +1 , lg = 20 , sq =1700   , inf = 1e18, maxk = 2022 , mod =998244353;
int s[maxn] , t[maxn] , x[maxn];

int sl(){
  int mn = inf ;
  rep(i , 0 ,25){ 
    if(x[i]==0)continue ; 
    mn = min(mn , s[i]/x[i]) ; 
  }
  return mn ; 
}

signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);   
  int z ;cin >> z ; 
  while(z--){
    string A , B;
    cin >> A >> B ;
    int ans =1  ;
    rep(i , 0 , 25)s[i] = t[i]= x[i] = 0 ;
    rep(i , 0 ,sz(A)-1)s[A[i]-'a']++;
    rep(i , 0 ,sz(B)-1)t[B[i]-'a']++;
    rep(i , 0 , 25){
      if(s[i] < t[i]){
        ans =0 ;
        break ;
      }
      s[i] -= t[i] ; 
    }
    if(ans == 0){
      cout << "0\n" ;
      continue ;
    }
    rep(i , 0 , 25)x[i] = (t[i]+1)/2 ;
    int mx = sl()  ;
    rep(i ,2 , sz(A)){
      bool ok = 0 ;
      rep(j , 0 ,25){
        x[j] = t[j] / i ;
        if(t[j]%i > x[j])ok = 1; 
      }
      if(ok == 1)continue ; 
      mx = max(mx , sl()); 
    }
    cout << 1+mx << "\n" ;
  }
}
/*
*/

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 7780kb

input:

2
bajkaaall aal
abca cba

output:

2
1

result:

ok 2 number(s): "2 1"

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 7684kb

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
1
2
0
0
0
0
1

result:

wrong answer 10th numbers differ - expected: '2', found: '1'