链接:

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. Docker 制作定制asp.netcore 的容器

    上文Windows docker k8s asp.net core的k8swebap镜像只是一个asp.net core程序,在实际生产中我们希望容器中还有一些其他程序,比如ssh 和telegraf ...

  2. Java学习:内部类的概念于分类

    内部类的概念于分类 如果一个事物的内部类包含另一个事物,那么这就是一个类内部包含另一个类.例如:身体和心脏的关系,又如:汽车和发动机的关系. 分类 成员内部类 局部内部类(包含匿名内部类) 成员内部类 ...

  3. -UI调试工具 SAK 布局 MD

    目录 目录 SwissArmyKnife 接入方式 自动初始化版本 支持的功能 可配置项 原理 自定义功能 Markdown版本笔记 我的GitHub首页 我的博客 我的微信 我的邮箱 MyAndro ...

  4. C#安装和卸载windowsService的bat指令

    只需新建2个文本文档,将2个指令分别复制进去,再将txt格式改为bat格式,以管理员身份运行 安装指令 %SystemRoot%\Microsoft.NET\Framework\v4.0.30319\ ...

  5. 递归求兔子数列第n项的值

    #include <iostream> using namespace std; int f(int n)//递归f数列的第n项 { ,y=,z; ||n==) { ; } else { ...

  6. Android 8.0的平台上,应用不能对大部分的广播进行静态注册

    引言在Android 8.0的平台上,应用不能对大部分的广播进行静态注册,也就是说,不能在AndroidManifest文件对有些广播进行静态注册,这里必须强调是有些广播,因为有些广播还是能够注册的. ...

  7. 图解再谈ssh port forwarding-ssh隧道技术

    https://www.ramkitech.com/2012/04/how-to-do-ssh-tunneling-port-forwarding.html https://www.cnblogs.c ...

  8. javascript原型深入解析1-prototype 和原型链、js面向对象

    1.用prototype 封装类 创建的每个函数都有一个prototype(原型属性),他是个指针,指向的对象,这个对象的用途就是包含了这个类型所有实例共享的属性和方法. 回味这句,想想java或者C ...

  9. 一篇文章搞定redis

    Redis 简介 Redis 是完全开源免费的,遵守 BSD 协议,是一个高性能的 key - value 数据库 Redis 与 其他 key - value 缓存产品有以下三个特点: Redis ...

  10. 【Java并发编程】24、Synchronized实现原理解析

    一.概述 我们知道在JDK1.5之前synchronized是一个重量级锁,相对于j.u.c.Lock,它会显得那么笨重,以至于我们认为它不是那么的高效而慢慢摒弃它. 不过,随着后续Java版本更新对 ...