题目:

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. oracle type类型

    转载 http://blog.sina.com.cn/s/blog_6cfb6b090100ve92.html 转自网络,具体用法我会再细化 1.概念    方法:是在对象类型说明中用关键字  MEM ...

  2. bzoj2287

    背包+fft 既然要不选一个东西,那么我们求出前缀背包和后缀背包,每次答案就是f[i-1][w]*g[i+1][j-w] 但是这样复杂度还是n^3,跑不过,但是我们发现上面那个东西不就是个裸卷积吗,直 ...

  3. Java 链式写法

    Java链式写法,子类继承父类的属性,也可以返回子类的对象,只是需要重写基类的Set方法 public class MyLS { public static void main(String[] ar ...

  4. bzoj 1592: [Usaco2008 Feb]Making the Grade 路面修整【dp】

    因为是单调不降或单调不升,所以所有的bi如果都是ai中出现过的一定不会变差 以递增为例,设f[i][j]为第j段选第i大的高度,预处理出s[i][j]表示选第i大的时,前j个 a与第i大的值的差的绝对 ...

  5. c#自定义ORM框架---(泛型&反射&实体类扩展属性<附带通用增、删、查、改>)

    该教材主要是运用到泛型.反射和实体类扩展属性 步骤一.建立扩展属性类 实体类扩展属性要继承Attribute基类完成 [AttributeUsage(AttributeTargets.Property ...

  6. mycat查表报错Invalid DataSource:0解决方法

    报错时机 登录没问题 use库没问题 select任意一张表均报错 报错信息 mysql> select * from mydb.tb_user; ERROR 3009 (HY000): jav ...

  7. sql 数据库建表

    1. 需求 打分和备注是两条记录显示,打分和备注应该放到一张里面吗?放到一张表里面,展示好一些,自己一张表搞定,如果再创建一张表存储备注,需要union all 来进行关联, 感觉性能上有些影响,但是 ...

  8. 402 Remove K Digits 移掉K位数字

    给定一个以字符串表示的非负整数 num,移除这个数中的 k 位数字,使得剩下的数字最小.注意:    num 的长度小于 10002 且 ≥ k.    num 不会包含任何前导零.示例 1 :输入: ...

  9. 02使用常规步骤编译NanoPiM1Plus的Android4.4.2

    02使用常规步骤编译NanoPiM1Plus的Android4.4.2 大文实验室/大文哥 壹捌陆捌零陆捌捌陆捌贰 21504965 AT qq.com 完成时间:2017/12/5 17:51 版本 ...

  10. html5前端杂记

    首先是css的一些知识 毕竟自己懂得不多,但是一看资料.感觉似曾相识 <style> .red-text { color: red; } </style>//这里是css样式的 ...