I have read the tutorial of this problem and I haven't found any problem .But it's getting WA.↵
I don't know why it's getting WA. I want some critical testcases.↵
Here is my code:↵
#include<bits/stdc++.h>↵
using namespace std;↵
#define ll long long int↵
int n,m,i,c[100005],a,b,v,k,t[100005];↵
set<int> g[100005];↵
vector<int>first_half;↵
vector<int>second_half;↵
vector<int>total;↵
int par[209],group[209];↵
int arra[150000];↵
vector<int>arr;↵
map<char,int>cp;↵
map<ll,ll>mp;↵
deque<char>stp1;↵
deque<char>stp2;↵
map<int,int>pos;↵
map<string,int>check;↵
map<string,string>server;↵
vector<string>ans1;↵
vector<string>ans2;↵
vector<string>ans3;↵
string server1[1009];↵
string ip1[1009];↵
string server2[1009];↵
string ip2[1009];↵
ll cashier[109];↵
ll fir[10009];↵
ll sec[100009];↵
ll dice[109];↵
vector<ll>element;↵
map<ll,ll>skysc;↵
map<string,ll>iteams;↵
map<ll,ll>equal1;↵
map<ll,ll>equalcnt;↵
ll complete[200009][29];↵
map<ll,ll>vis_pos;↵
map<char,ll>complete_cp;↵
int main() {↵
ll t; ↵
cin>>t;↵
while(t--){ ↵
ll i,j,k,l=0,p=0,q=2019,n,r,ans=100000000,x,mini=100000000000000,maxi,z=0,total=0;↵
string item;↵
// cin>>n;↵
cin>>n>>k;↵
string stk;↵
cin>>stk;↵
l=n/k+1;↵
↵
↵
for(i=1;i<=l;i++)↵
{↵
↵
↵
↵
maxi=0;↵
z=0;↵
↵
for(j=0;j<=n;j=j+k)↵
{↵
↵
if(i+j-1<=n-1&&vis_pos[i+j-1]==0){↵
complete_cp[stk[i+j-1]]++;↵
maxi=max(maxi,complete_cp[stk[i+j-1]]);↵
vis_pos[i+j-1]++;↵
z++;↵
// cout<<complete_cp[stk[i+j-1]]<<'\n';↵
}↵
if(j-i>=0&&vis_pos[j-i]==0){↵
complete_cp[stk[j-i]]++;↵
maxi=max(maxi,complete_cp[stk[j-i]]);↵
// cout<<complete_cp[stk[n-(i+j)]]<<'\n';↵
vis_pos[j-i]++;↵
z++;↵
}↵
}↵
if(maxi>0)↵
total=total+max(p,z-maxi);↵
//cout<<maxi<<" "; ↵
// complete_cp.clear();↵
complete_cp.clear();↵
↵
}↵
↵
↵
//cout<<n/k+n/k-maxi<<" ";↵
↵
↵
↵
complete_cp.clear();↵
↵
↵
↵
cout<<total<<'\n';↵
vis_pos.clear();↵
↵
↵
↵
}↵
↵
↵
}https://ideone.com/DABn29↵
↵
Thanks in advance..↵
↵
↵
↵
↵
↵
↵
↵
↵
↵
I don't know why it's getting WA. I want some critical testcases.↵
Here is my code:↵
using namespace std;↵
#define ll long long int↵
int n,m,i,c[100005],a,b,v,k,t[100005];↵
set<int> g[100005];↵
vector<int>first_half;↵
vector<int>second_half;↵
vector<int>total;↵
int par[209],group[209];↵
int arra[150000];↵
vector<int>arr;↵
map<char,int>cp;↵
map<ll,ll>mp;↵
deque<char>stp1;↵
deque<char>stp2;↵
map<int,int>pos;↵
map<string,int>check;↵
map<string,string>server;↵
vector<string>ans1;↵
vector<string>ans2;↵
vector<string>ans3;↵
string server1[1009];↵
string ip1[1009];↵
string server2[1009];↵
string ip2[1009];↵
ll cashier[109];↵
ll fir[10009];↵
ll sec[100009];↵
ll dice[109];↵
vector<ll>element;↵
map<ll,ll>skysc;↵
map<string,ll>iteams;↵
map<ll,ll>equal1;↵
map<ll,ll>equalcnt;↵
ll complete[200009][29];↵
map<ll,ll>vis_pos;↵
map<char,ll>complete_cp;↵
int main() {↵
ll t; ↵
cin>>t;↵
while(t--){ ↵
ll i,j,k,l=0,p=0,q=2019,n,r,ans=100000000,x,mini=100000000000000,maxi,z=0,total=0;↵
string item;↵
// cin>>n;↵
cin>>n>>k;↵
string stk;↵
cin>>stk;↵
l=n/k+1;↵
↵
↵
for(i=1;i<=l;i++)↵
{↵
↵
↵
↵
maxi=0;↵
z=0;↵
↵
for(j=0;j<=n;j=j+k)↵
{↵
↵
if(i+j-1<=n-1&&vis_pos[i+j-1]==0){↵
complete_cp[stk[i+j-1]]++;↵
maxi=max(maxi,complete_cp[stk[i+j-1]]);↵
vis_pos[i+j-1]++;↵
z++;↵
// cout<<complete_cp[stk[i+j-1]]<<'\n';↵
}↵
if(j-i>=0&&vis_pos[j-i]==0){↵
complete_cp[stk[j-i]]++;↵
maxi=max(maxi,complete_cp[stk[j-i]]);↵
// cout<<complete_cp[stk[n-(i+j)]]<<'\n';↵
vis_pos[j-i]++;↵
z++;↵
}↵
}↵
if(maxi>0)↵
total=total+max(p,z-maxi);↵
//cout<<maxi<<" "; ↵
// complete_cp.clear();↵
complete_cp.clear();↵
↵
}↵
↵
↵
//cout<<n/k+n/k-maxi<<" ";↵
↵
↵
↵
complete_cp.clear();↵
↵
↵
↵
cout<<total<<'\n';↵
vis_pos.clear();↵
↵
↵
↵
}↵
↵
↵
}
↵
Thanks in advance..↵
↵
↵
↵
↵
↵
↵
↵
↵
↵