链接:

https://codeforces.com/contest/1263/problem/B

题意:

A PIN code is a string that consists of exactly 4 digits. Examples of possible PIN codes: 7013, 0000 and 0990. Please note that the PIN code can begin with any digit, even with 0.

Polycarp has n (2≤n≤10) bank cards, the PIN code of the i-th card is pi.

Polycarp has recently read a recommendation that it is better to set different PIN codes on different cards. Thus he wants to change the minimal number of digits in the PIN codes of his cards so that all n codes would become different.

Formally, in one step, Polycarp picks i-th card (1≤i≤n), then in its PIN code pi selects one position (from 1 to 4), and changes the digit in this position to any other. He needs to change the minimum number of digits so that all PIN codes become different.

Polycarp quickly solved this problem. Can you solve it?

思路:

n最大是10, 直接暴力修改

代码:

#include<bits/stdc++.h>
using namespace std; int main()
{
int t;
cin >> t;
while(t--)
{
int n;
string s[10];
map<string, int> Mp;
cin >> n;
for (int i = 0;i < n;i++)
cin >> s[i], Mp[s[i]]++;
int ans = 0;
for (int i = 0;i < n;i++)
{
if (Mp[s[i]] > 1)
{
ans++;
Mp[s[i]]--;
for (int j = 0;j < 10;j++)
{
s[i][0] = j+'0';
if (Mp[s[i]] == 0)
break;
}
Mp[s[i]]++;
}
}
cout << ans << endl;
for (int i = 0;i < n;i++)
cout << s[i] << endl;
} return 0;
}

Codeforces Round #603 (Div. 2) B. PIN Codes的更多相关文章

  1. Codeforces Round #603 (Div. 2) B. PIN Codes 水题

    B. PIN Codes A PIN code is a string that consists of exactly 4 digits. Examples of possible PIN code ...

  2. Codeforces Round #603 (Div. 2) A. Sweet Problem(水.......没做出来)+C题

    Codeforces Round #603 (Div. 2) A. Sweet Problem A. Sweet Problem time limit per test 1 second memory ...

  3. Codeforces Round #603 (Div. 2)

    传送门 感觉脑子还是转得太慢了QAQ,一些问题老是想得很慢... A. Sweet Problem 签到. Code /* * Author: heyuhhh * Created Time: 2019 ...

  4. Codeforces Round #603 (Div. 2) E. Editor 线段树

    E. Editor The development of a text editor is a hard problem. You need to implement an extra module ...

  5. Codeforces Round #603 (Div. 2) E. Editor(线段树)

    链接: https://codeforces.com/contest/1263/problem/E 题意: The development of a text editor is a hard pro ...

  6. Codeforces Round #603 (Div. 2) (题解)

    A. Sweet Problem (找规律) 题目链接 大致思路: 有一点瞎猜的,首先排一个序, \(a_1>a_2>a_3\) ,发现如果 \(a_1>=a_2+a_3\) ,那么 ...

  7. Codeforces Round #603 (Div. 2) D. Secret Passwords 并查集

    D. Secret Passwords One unknown hacker wants to get the admin's password of AtForces testing system, ...

  8. Codeforces Round #603 (Div. 2) D. Secret Passwords(并查集)

    链接: https://codeforces.com/contest/1263/problem/D 题意: One unknown hacker wants to get the admin's pa ...

  9. Codeforces Round #603 (Div. 2) C. Everyone is a Winner! (数学)

    链接: https://codeforces.com/contest/1263/problem/C 题意: On the well-known testing system MathForces, a ...

随机推荐

  1. 《算法竞赛进阶指南》 1 (P4) a^b 快速幂

    快速幂 #include<cstdio> #include<cmath> #include<iostream> using namespace std; long ...

  2. 关于FMX 单击出来右键菜单,并显示在当前下面

    关于FMX  单击出来右键菜单,并显示在当前下面 procedure TForm1.btn6MouseDown(Sender: TObject; Button: TMouseButton; Shift ...

  3. LOJ2874 JOISC2014 历史研究 分块、莫队

    传送门 看到出现次数自然地考虑莫队. 但是发现如果需要删除并动态维护答案的话,则要用一个堆来维护答案,增加了一个\(log\).但是加入操作却没有这个\(log\),所以我们考虑避免删除操作. 分块, ...

  4. ML学习笔记之TF-IDF原理及使用

    0x00 什么是TF-IDF TF-IDF(Term Frequency-Inverse Document Frequency, 词频-逆文件频率). # 是一种用于资讯检索与资讯探勘的常用加权技术. ...

  5. AnimationClip压缩-动画文件压缩

    动画压缩方法一.常用方法1. Rig->Animation Type:改为Generic2. Animations->Anim.Compression:Optimal二.高级方法1. 去掉 ...

  6. springboot WebMvcConfigurer配置静态资源和解决跨域

    前言 虽然现在都流行前后端分离部署,但有时候还是需要把前端文件跟后端文件一起打包发布,这就涉及到了springboot的静态资源访问的问题.不单只是静态资源打包,比如使用本地某个目录作为文件存储,也可 ...

  7. [Cocos Creator]安卓上微信小游戏加载到100%就进不去了

    最近用Cocos Creator 开发微信小游戏,构建发布到微信上,用安卓手机预览打开后加载到100%就不动了,开始以为微信开发工具版本的问题,后来用苹果的手机测试了一下,发现也有同样的问题. 仔细分 ...

  8. [摘抄] 4.require命令

    4.require命令 1. 基本用法 Node适用CommonJS模块规范,内置的require命令用于加载模块文件. require命令的基本功能是,读入并执行一个JavaScript文件,然后返 ...

  9. Ext.urlEncode与Ext.urlDecode

    Ext.urlEncode与Ext.urlDecode: 用于js对象和查询字符串之间的相互转换 Ext.urlEncode例子如下: /* Ext.urlEncode( object, [recur ...

  10. Java 之 Arrays 类

    一.概述 java.util.Arrays 此类包含用来操作数组的各种方法.比如排序和搜索等,其所有方法均为静态方法,调用非常方便. 二.操作数组的方法 (1)使用二分搜索法来搜索指定的 int 型数 ...