题目:

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. 经典的printk 写法

    经典的printk 写法: printk("[lynn--%s@%d]: addr:0x%x  \n",__func__,__LINE__,obj->client->a ...

  2. 10.6 Graph Test

    一套图论的练习题,各个方面都有挺好的 第一第二题有一定难度(来源POI),第三第四题比较水 但我并没考好 T1 特工 szp T2 洞穴 zaw T3 最短路 line T4 最小差异值 dvalue

  3. Cocos2dx如何引用第三方SO文件(Android NDK)

    做项目的过程中发现,引用第三方的库lib3rdsdk.so,当直接把lib3rdsdk.so放进armeabi文件夹里,会被删除掉.查网上资料都说的不全,经过实验,最简单的方法就是在jni下的andr ...

  4. [Codeforces 496E] Distributing Parts

    [题目链接] https://codeforces.com/contest/496/problem/E [算法] 按右端点排序 , 每个乐曲优先选取的左端点最大的演奏家 用std :: set维护贪心 ...

  5. JSSDK使用步骤

    绑定域名 先登录微信公众平台进入“公众号设置”的“功能设置”里填写“JS接口安全域名”. 备注:登录后可在“开发者中心”查看对应的接口权限. 引入js文件 在需要调用JS接口的页面引入如下JS文件,( ...

  6. 正则表达式:(?=a)是什么意思?

    1.(?=a) 表示我们需要匹配某样东西的前面. 2.(?!a) 表示我们需要不匹配某样东西. 3.(?:a) 表示我们需要匹配某样东西本身. 4.(?<=a) 表示我们需要匹配某样东西的后面. ...

  7. F5 SSLVPN 的安装问题

    WIN10下安装SSLVPN问题 1.右击计算机 -->选择管理-->查看安装的插件是否显示感叹号 2.如果显示感叹号-->则进行更新驱动-->>手动选择-->网络 ...

  8. js滚轮事件需要注意的兼容性问题

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  9. vs2017 + miniUI 后端框架使用

    vs2017 +  miniUI  后端框架使用 上miniUI官网直接下载框架.http://www.miniui.com/ 此框架使用说明很清楚. 2.1.vs2017创建安装miniUI后端框架 ...

  10. MongoDB一些常用指令与他的JavaScript的对应表