Registration system(map)

本文介绍了一个关于新电子邮件服务Berlandesk的注册系统原型,如何处理用户注册时的姓名冲突,通过生成唯一的新用户名规则。通过输入的姓名检查数据库,确保唯一性并返回响应或提示新用户名。

A new e-mail service "Berlandesk" is going to be opened in Berland in the near future. The site administration wants to launch their project as soon as possible, that's why they ask you to help. You're suggested to implement the prototype of site registration system. The system should work on the following principle.

Each time a new user wants to register, he sends to the system a request with his name. If such a name does not exist in the system database, it is inserted into the database, and the user gets the response OK, confirming the successful registration. If the name already exists in the system database, the system makes up a new user name, sends it to the user as a prompt and also inserts the prompt into the database. The new name is formed by the following rule. Numbers, starting with 1, are appended one after another to name (name1, name2, ...), among these numbers the least i is found so that namei does not yet exist in the database.

Input

The first line contains number n (1 ≤ n ≤ 105). The following n lines contain the requests to the system. Each request is a non-empty line, and consists of not more than 32 characters, which are all lowercase Latin letters.

Output

Print n lines, which are system responses to the requests: OK in case of successful registration, or a prompt with a new name, if the requested name is already taken.

Examples

Input

4
abacaba
acaba
abacaba
acab

Output

OK
OK
abacaba1
OK

Input

6
first
first
second
second
third
third

Output

OK
first1
OK
second1
OK
third1

 利用map记录出现次数的题目

#include<iostream>
#include<stdio.h>
#include<string.h>
#include<map>
using namespace std;
int main()
{
	string s;
	int n;
	map<string, int> m;
	cin>>n;
	while (n--)
	{
		cin>>s;
		m[s]++;
		if (m[s]>1)
		cout<<s<<m[s]-1<<endl;
		else
		cout<<"OK"<<endl;
	}
	return 0;
}

 

【路径规划】(螺旋)基于A星全覆盖路径规划研究(Matlab代码实现)内容概要:本文围绕“基于A星算法的全覆盖路径规划”展开研究,重点介绍了一种结合螺旋搜索策略的A星算法在栅格地图中的路径规划实现方法,并提供了完整的Matlab代码实现。该方法旨在解决移动机器人或无人机在未知或部分已知环境中实现高效、无遗漏的区域全覆盖路径规划问题。文中详细阐述了A星算法的基本原理、启发式函数设计、开放集与关闭集管理机制,并融合螺旋遍历策略以提升初始探索效率,确保覆盖完整性。同时,文档提及该研究属于一系列路径规划技术的一部分,涵盖多种智能优化算法与其他路径规划方法的融合应用。; 适合人群:具备一定Matlab编程基础,从事机器人、自动化、智能控制及相关领域研究的研究生、科研人员及工程技术人员。; 使用场景及目标:①应用于服务机器人、农业无人机、扫地机器人等需要完成区域全覆盖任务的设备路径设计;②用于学习和理解A星算法在实际路径规划中的扩展应用,特别是如何结合特定搜索策略(如螺旋)提升算法性能;③作为科研复现与算法对比实验的基础代码参考。; 阅读建议:建议结合Matlab代码逐段理解算法实现细节,重点关注A星算法与螺旋策略的切换逻辑与条件判断,并可通过修改地图环境、障碍物分布等方式进行仿真实验,进一步掌握算法适应性与优化方向。
public static void main(String[] args) throws Exception { System.out.println("请输入账号"); String account = Common.sc.next(); System.out.println("请输入密码"); String password =Common.sc.next(); Class.forName("com.mysql.cj.jdbc.Driver"); Connection conn = DriverManager.getConnection( "jdbc:mysql://117.72.189.79 : 3306/jx2510" , "root" , "Fbb608425@"); String sql = "select * from user where account = ? and password = ?"; PreparedStatement ps = conn.prepareStatement(sql); ps.setString(1, account); ps.setString(2, password); ResultSet rs = ps.executeQuery(); if (rs.next()) { System.out.println("登录成功"); System.out.println(); System.out.println("请输入地图X轴边界"); int mapX = Common.sc.nextInt(); System.out.println("请输入地图Y轴边界"); int mapY = Common.sc.nextInt(); System.out.println("请输入老鼠数量"); int mouseNumber = Common.sc.nextInt(); GameMap gameMap = new GameMap(mapX, mapY, mouseNumber); Player player = new Player(); while (true) { gameMap.putMouse(); gameMap.showMap(); player.getPlayerInput(); MouseFather hitMouse = gameMap.getMap()[player.getHitX()][player.getHitY()]; if (hitMouse != null) { System.out.println("恭喜你,打中了..."); hitMouse.cry(); int type = hitMouse.getType(); player.setScore(player.getScore() + type); } else { System.out.println("很可惜,没打中..."); player.setScore(player.getScore() - 1); } System.out.println("当前玩家的分数为: " + player.getScore()); if (player.getScore() == 0 || player.getScore() >= 10) { System.out.println("游戏结束 " + (player.getScore() == 0 ? "游戏失败" : "游戏胜利")); System.out.println("是否重新开始游戏? 1-重新开始 其他-结束游戏"); int choice = Common.sc.nextInt(); if (choice == 1) { player.setScore(3); } else { System.out.println("再见,欢迎再次游玩"); break; } } gameMap.freshMap(); } }else { System.out.println("登陆失败"); } rs.close(); ps.close(); conn.close(); }添加注册功能,要求把账号密码存储数据库中
11-12
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值