1,Array Cloning Technique;2,19届省赛总结
1,Array Cloning Technique
用unordered_map<>被卡哈希了,用map能过;
map的操作时间复杂度稳定为logn,而unordered_map在遇到哈希冲突时可能会被卡成O(n),从而导致tle;
#include<bits/stdc++.h>
#define rep1(i,a,n) for(register int i=a;i<n;i++)
#define rep2(i,a,n) for(register int i=a;i<=n;i++)
#define per1(i,n,a) for(register int i=n;i>a;i--)
#define per2(i,n,a) for(register int i=n;i>=a;i--)
#define quick_cin() cin.tie(0),cout.tie(0),ios::sync_with_stdio(false)
#define INF 0x3f3f3f3f
#define pb push_back
#define endl "\n"
#define xiaoshu(a) setprecision(a)
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
void solve()
{
ll n;
cin>>n;
map<ll,ll>hs;
ll maxx=0;
rep2(i,1,n)
{
ll x;
cin>>x;
hs[x]++;
if(hs[x]>maxx)maxx=hs[x];
}
ll ans=n-maxx;
if(maxx==n)cout<<0<<endl;
else
{
while(1)
{
maxx*=2;
ans++;
if(n<=maxx)break;
}
cout<<ans<<endl;
}
}
signed main()
{
quick_cin();
int T;
cin>>T;
while(T--)solve();
return 0;
}
2,其实感觉还可以,过了5道,挺满意的了但是第六个题我花了两个半小时,最后半小时队友也来帮我,但是还是wa,wa有6发把。。。,队友也看不出来哪里错了,感觉都挺对的,但是最后还是没能ac掉这个easy glid!!大一,弱校,这个成绩勉强接受,来年再战!!