题目:

The gaming company Sandstorm is developing an online two player game. You have been asked to implement the ranking system. All players have a rank determining their playing strength which gets updated after every game played. There are 25 regular ranks, and an extra rank, “Legend”, above that. The ranks are numbered in decreasing order, 25 being the lowest rank, 1 the second highest rank, and Legend the highest rank.

Each rank has a certain number of “stars” that one needs to gain before advancing to the next rank. If a player wins a game, she gains a star. If before the game the player was on rank 6-25, and this was the third or more consecutive win, she gains an additional bonus star for that win. When she has all the stars for her rank (see list below) and gains another star, she will instead gain one rank and have one star on the new rank.

For instance, if before a winning game the player had all the stars on her current rank, she will after the game have gained one rank and have 1 or 2 stars (depending on whether she got a bonus star) on the new rank. If on the other hand she had all stars except one on a rank, and won a game that also gave her a bonus star, she would gain one rank and have 1 star on the new rank.

If a player on rank 1-20 loses a game, she loses a star. If a player has zero stars on a rank and loses a star, she will lose a rank and have all stars minus one on the rank below. However, one can never drop below rank 20 (losing a game at rank 20 with no stars will have no effect).

If a player reaches the Legend rank, she will stay legend no matter how many losses she incurs afterwards.

The number of stars on each rank are as follows:

• Rank 25-21: 2 stars

• Rank 20-16: 3 stars

• Rank 15-11: 4 stars

• Rank 10-1: 5 stars

A player starts at rank 25 with no stars. Given the match history of a player, what is her rank at the end of the sequence of matches?

Input:

The input consists of a single line describing the sequence of matches. Each character corresponds to one game; ‘W’ represents a win and ‘L’ a loss. The length of the line is between 1 and 10 000 characters (inclusive).

Output:

Output a single line containing a rank after having played the given sequence of games; either an integer between 1 and 25 or “Legend”.

题意:

“炉石传说”排位模拟,条件真的多啊,列出所有的条件慢慢来就ok了。

条件:

  1. 每个Rank的star的个数如上。
  2. 如果玩家Rank处于6-25之间,那么只要连赢3场及更多场,每次加2颗star,否则赢了只能加一颗star。
  3. 当玩家升至Rank后就不会再掉到Rank20以下,也就是说当玩家在Rank20+0star时输了比赛,并不会掉Rank。
  4. 当玩家在Rank Legend的时候,输赢将不会再产生影响。
  5. 当玩家处于Rank x + 0star 输掉比赛,玩家的段位变为Rank (x+1)+ full-1 star,full-1也就是下一个段位最大star数减一。

注意到以上条件开工写代码:

代码:

#include <bits/stdc++.h>
#define FRE() freopen("in.txt","r",stdin)
using namespace std;
const int maxn = 1e4+;
typedef long long ll; struct Player
{
int rak;
int star;
Player()
{
rak = ;
star = ;
}
}; int judgeFullWin(int x,int star)//得到Rank上升后的star的个数
{
if(x>= && x<=)
return star-;
else if(x>= && x<=)
return star-;
else if(x>= && x<=)
return star-;
else if(x>= && x<=)
return star-;
} int judgeFullLose(int r)//返回每个Rank对应的最大的star的个数
{
if(r>= && r<=)
return ;
else if(r>= && r<=)
return ;
else if(r>= && r<=)
return ;
else if(r>= && r<=)
return ;
} int main()
{
Player p;
char str[maxn];
scanf("%s",&str);
int cw = ;
for(int i = ; str[i]; i++)
{
if(str[i]=='W' && (p.rak>= && p.rak<=))
{
if(p.rak>= && p.rak<=)//6-25获胜
{
cw++;//连胜率
if(cw>=)
{
int s = judgeFullWin(p.rak, p.star+);
if(s > )
{
p.rak--;
p.star = s;
}
else
p.star+=;
}
else
{
int s = judgeFullWin(p.rak, p.star+);
//printf("S: %d\n",s);
if(s > )
{
p.rak--;
p.star = s;
}
else
p.star++;
}
}
else if(p.rak>= && p.rak<=)
{
int s = judgeFullWin(p.rak, p.star+);
if(s > )
{
p.rak--;
p.star = s;
}
else
p.star++;
}
}
else if(str[i]=='L' && (p.rak>= && p.rak<=))
{
cw = ;//连胜率为0
if(p.rak>= && p.rak<=)
{
if((p.rak== && p.star == )||(p.rak== && p.star == ))
continue;
if(p.star==)
{
p.star = judgeFullLose(p.rak+)-;
p.rak++;
}
else
p.star--;
} }
}
if(p.rak == )
printf("Legend\n");
else
printf("%d\n",p.rak); return ;
}
/*
样例输入:
WW
WWW
WWWW
WLWLWLWL
WWWWWWWWWLLWW
WWWWWWWWWLWWL
样例输出:
25
24
23
24
19
18
*/

二刷思路清晰,代码显然要简洁多了!

#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <iomanip>
#define MAX 1000000000
#define inf 0x3f3f3f3f
#define FRE() freopen("in.txt","r",stdin) using namespace std;
typedef long long ll;
const int maxn = ;
char str[maxn]; int query(int rk)
{
if(rk>= && rk<=) return ;
if(rk>= && rk<=) return ;
if(rk>= && rk<=) return ;
if(rk>= && rk<=) return ;
} void BeWin(int& rk,int& con,int& star)
{
if(rk==)
return;
else if(rk>= && rk<=)
{
if(con>=) star+=;
else star++;
if(star > query(rk))
{
star = star-query(rk);
rk--;
}
}
else
{
star++;
if(star > query(rk))
{
star = star-query(rk);
rk--;
}
}
} void BeLost(int& rk,int& star)
{
if(rk==)
return;
else if(rk>= && rk<=)
{
if(star==)
{
if(rk<)
{
rk++;
star = query(rk)-;
}
}
else
{
star--;
}
}
} int main()
{
scanf("%s",str);
int len = strlen(str);
int rk = ,con = ,star=;
for(int i=; i<len; i++)
{
if(str[i]=='W')
{
con++;
BeWin(rk,con,star);
}
if(str[i]=='L')
{
con = ;
BeLost(rk,star);
}
}
if(rk==)
printf("Legend\n");
else
printf("%d\n",rk);
return ;
}

Game Rank(NCPC 2016 大模拟)的更多相关文章

  1. HDU 5920 Ugly Problem 高精度减法大模拟 ---2016CCPC长春区域现场赛

    题目链接 题意:给定一个很大的数,把他们分为数个回文数的和,分的个数不超过50个,输出个数并输出每个数,special judge. 题解:现场赛的时候很快想出来了思路,把这个数从中间分为两部分,当位 ...

  2. AC日记——神奇的幻方 洛谷 P2615(大模拟)

    题目描述 幻方是一种很神奇的N*N矩阵:它由数字1,2,3,……,N*N构成,且每行.每列及两条对角线上的数字之和都相同. 当N为奇数时,我们可以通过以下方法构建一个幻方: 首先将1写在第一行的中间. ...

  3. ACdream 1188 Read Phone Number (字符串大模拟)

    Read Phone Number Time Limit:1000MS     Memory Limit:64000KB     64bit IO Format:%lld & %llu Sub ...

  4. [BZOJ 4573][ZJOI 2016]大森林

    [LOJ 2092][BZOJ 4573][UOJ 195][ZJOI 2016]大森林 题意 给定一个树序列, 初始时所有树都只有一个点, 要求支持三种操作: 区间种树(在某个特定点上长出一个子结点 ...

  5. 2016ACM-ICPC网络赛北京赛区 1001 (trie树牌大模拟)

    [题目传送门] 1383 : The Book List 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 The history of Peking University ...

  6. Bzoj1972: [Sdoi2010]猪国杀 题解(大模拟+耐心+细心)

    猪国杀 - 可读版本 https://mubu.com/doc/2707815814591da4 题目可真长,读题都要一个小时. 这道题很多人都说不可做,耗时间,代码量大,于是,本着不做死就不会死的精 ...

  7. (大模拟紫题) Luogu P1953 易语言

    原题链接:P1953 易语言 (我最近怎么总在做大模拟大搜索题) 分别处理两种情况. 如果只有一个1或0 直接设一个cnt为这个值,每次输入一个新名字之后把数字替换成cnt,最后cnt++即可. 注意 ...

  8. NOIP2017 时间复杂度 大模拟

    再写一道大模拟题. 由于是限时写的,相当于考场代码,乱的一批. 题目链接:P3952 时间复杂度 先记几个教训: 字符串形式的数字比较大小老老实实写函数,字典序都搞错几次了 栈空的时候不但pop()会 ...

  9. [CSP-S模拟测试]:引子(大模拟)

    题目描述 网上冲浪时,$Slavko$被冲到了水箱里,水箱由上而下竖直平面.示意图如下: 数字$i$所在的矩形代表一个编号为$i$的水箱.1号水箱为水箱中枢,有水管连出.除了$1$号水箱外,其他水箱上 ...

随机推荐

  1. poj 1459 多源汇网络流 ISAP

    题意: 给n个点,m条边,有np个源点,nc个汇点,求最大流 思路: 超级源点把全部源点连起来.边权是该源点的最大同意值: 全部汇点和超级汇点连接起来,边权是该汇点的最大同意值. 跑最大流 code: ...

  2. 怎样处理Gradle中的这个文件下载慢的问题的

    如图:在build.gradle中的dependencies中加上要依赖的包后,就点击sync gradle.然后就开始了下载.在此过程中我是FQ了的(在此同时我是可以用chrome进入https:/ ...

  3. TQ210--UBOOT移植笔记--添加自己的单板【学习笔记】

    在uboot的源码的根目录下的readme中有介绍如何在uboot中添加自己的单板: 一.在boards.cfg中添加自己的单板的信息,可以模仿smdkc100去添加自己的单板的信息 二.复制单板的配 ...

  4. HTTP权威指南阅读记录 - 第一章

    最近终于开始看<HTTP权威指南>了,第一章主要是简介一些基本的概念.下面列出一些常用,但还不是很了解的简单概念. 一.常见概念: 1.媒体类型 因特网上有数千种不同的数据类型,HTTP仔 ...

  5. SPOOL 命令使用实例【oracle导出纯文本格式文件】

    SPOOL 命令使用实例[oracle导出纯文本格式文件] SET echo off              --在用start命令执行一个sql脚本时,是否显示脚本中正在执行的SQL语句: SET ...

  6. java 基础 —— 文件操作(File)

    1. 基本成员: File.separator public class File implements Serializable, Comparable<File> { private ...

  7. python re正则表达式模块

    模块的的作用主要是用于字符串和文本处理,查找,搜索,替换等 复习一下基本的正则表达式吧  .:匹配除了换行符以为的任意单个字符  *:匹配任意字符,一个,零个,多个都能匹配得到 俗称贪婪模式 +:匹配 ...

  8. JSP-Runoob:JSP开发环境搭建

    ylbtech-JSP-Runoob:JSP开发环境搭建 1.返回顶部 1. JSP 开发环境搭建 JSP开发环境是您用来开发.测试和运行JSP程序的地方. 本节将会带您搭建JSP开发环境,具体包括以 ...

  9. linux下的zookeeper启动

    zookeeper的安装目录:/usr/local/zookeeper-3.4.6/bin/zkServer.sh; 配置文件路径:../conf/zoo.cfg 端口 :2181: ZooKeepe ...

  10. map的遍历方式(使用Junit测试)

    package cn.sdut.lah; import java.util.HashMap; import java.util.Iterator; import java.util.Map; impo ...