版本比较
题解:P15606 [ICPC 2021 Jakarta R] Uniform Maker
正文
增加 7 行删除 7 行
22 行未改动232425262727282930313232333435363536373839404041424344454546474848495051526 行未改动22 行未改动
signed main(){ ios::sync_with_stdio(false); cin.tie(0), cout.tie(0);
cin >> n >> m; for(int i = 0; i < n; i++){ cin >> a[i]; }
int ans = 0; for(int i = 0; i < m; i++){ //枚举每一位 memset(cnt, 0, sizeof(cnt)); //不要忘了初始化 memset(cnt, 0, sizeof(cnt)); //不要忘了初始化
for(int j = 0; j < n; j++){ //统计该位各字符出现次数 cnt[a[j][i] - 'a']++; }
int mmax = 0; for(int k = 0; k < 26; k++){ mmax = max(mmax, cnt[k]); }
ans += n - mmax; //该位最少的修改次数 }
cout << ans;
return 0;}6 行未改动