Game Rank(NCPC 2016 大模拟)
题目:
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了。
条件:
- 每个Rank的star的个数如上。
- 如果玩家Rank处于6-25之间,那么只要连赢3场及更多场,每次加2颗star,否则赢了只能加一颗star。
- 当玩家升至Rank后就不会再掉到Rank20以下,也就是说当玩家在Rank20+0star时输了比赛,并不会掉Rank。
- 当玩家在Rank Legend的时候,输赢将不会再产生影响。
- 当玩家处于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 大模拟)的更多相关文章
- HDU 5920 Ugly Problem 高精度减法大模拟 ---2016CCPC长春区域现场赛
题目链接 题意:给定一个很大的数,把他们分为数个回文数的和,分的个数不超过50个,输出个数并输出每个数,special judge. 题解:现场赛的时候很快想出来了思路,把这个数从中间分为两部分,当位 ...
- AC日记——神奇的幻方 洛谷 P2615(大模拟)
题目描述 幻方是一种很神奇的N*N矩阵:它由数字1,2,3,……,N*N构成,且每行.每列及两条对角线上的数字之和都相同. 当N为奇数时,我们可以通过以下方法构建一个幻方: 首先将1写在第一行的中间. ...
- ACdream 1188 Read Phone Number (字符串大模拟)
Read Phone Number Time Limit:1000MS Memory Limit:64000KB 64bit IO Format:%lld & %llu Sub ...
- [BZOJ 4573][ZJOI 2016]大森林
[LOJ 2092][BZOJ 4573][UOJ 195][ZJOI 2016]大森林 题意 给定一个树序列, 初始时所有树都只有一个点, 要求支持三种操作: 区间种树(在某个特定点上长出一个子结点 ...
- 2016ACM-ICPC网络赛北京赛区 1001 (trie树牌大模拟)
[题目传送门] 1383 : The Book List 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 The history of Peking University ...
- Bzoj1972: [Sdoi2010]猪国杀 题解(大模拟+耐心+细心)
猪国杀 - 可读版本 https://mubu.com/doc/2707815814591da4 题目可真长,读题都要一个小时. 这道题很多人都说不可做,耗时间,代码量大,于是,本着不做死就不会死的精 ...
- (大模拟紫题) Luogu P1953 易语言
原题链接:P1953 易语言 (我最近怎么总在做大模拟大搜索题) 分别处理两种情况. 如果只有一个1或0 直接设一个cnt为这个值,每次输入一个新名字之后把数字替换成cnt,最后cnt++即可. 注意 ...
- NOIP2017 时间复杂度 大模拟
再写一道大模拟题. 由于是限时写的,相当于考场代码,乱的一批. 题目链接:P3952 时间复杂度 先记几个教训: 字符串形式的数字比较大小老老实实写函数,字典序都搞错几次了 栈空的时候不但pop()会 ...
- [CSP-S模拟测试]:引子(大模拟)
题目描述 网上冲浪时,$Slavko$被冲到了水箱里,水箱由上而下竖直平面.示意图如下: 数字$i$所在的矩形代表一个编号为$i$的水箱.1号水箱为水箱中枢,有水管连出.除了$1$号水箱外,其他水箱上 ...
随机推荐
- spring 之 IOC 依赖注入详解
当我们对一个javaBean进行实例化时,在原本的情况下我们会选择新建一个接口,然后进行实例化,为了进一步降低耦合度我们还会使用工厂模式进行封装. 例: 当我们想要去造,Chinese.America ...
- window环境下在anconda中安装opencv
今日学习CNN神经网络,在用keras框架下搭建一个简单的模型的时候需要import cv2,我尝试了一下几种方法: 1. 在prompt输入 pip intall opencv-python 出现如 ...
- P4460 [CQOI2018]解锁屏幕
算是我比较擅长的类型,自己想想就会了.普通小状压,状态傻子都能想出来.一开始裸的枚举T了,30.后来与处理之后跑的飞起,就是不对,还是30分.后来看讨论版...mod竟然是1e8+7!!!这不有毒吗. ...
- 深入理解JMM(Java内存模型) --(四)volatile
volatile的特性 当我们声明共享变量为volatile后,对这个变量的读/写将会很特别.理解volatile特性的一个好方法是:把对volatile变量的单个读/写,看成是使用同一个监视器锁对这 ...
- hdu 1043 Eight
欸我一直以为双向bfs是搜完一半再搜另一半呢,妹想到是两个一起搜 然后队列里放的结构体里不能直接存答案,所以做一个邻接表一样的东西,直接指向需要的字符即可 记录状态用康托展开来hash 以及居然是多组 ...
- [C和指针] 4-语句、5-操作符和表达式
第4章 语句 4.1 表达式语句 C并不存在专门的"赋值语句",赋值就是一种操作,就像加法和减法一样,所以赋值就在表达式内进行. 你只要在表达式后面加上一个分号,就可以把表达式转变 ...
- 【洛谷2617_BZOJ1901】Dynamic Rankings(树套树)
题目: 洛谷 2617 BZOJ 1901 是权限题,\(n=10^4\) ,内存 128 MB :洛谷 2617 \(n=10^5\) ,内存 1024 MB ,数据比较坑. 分析: 蒟蒻初学树套树 ...
- Roslyn导致发布网站时报错:编译失败
最近新升级了Visual Studio 2017,创建的Web项目Bin目录中多了一个叫roslyn的文件夹,该文件夹导致网站在某些服务器上发布出错 从网上搜索了一下,Roslyn是新出的动态编译工具 ...
- 构建一个.net的干货类库,以便于快速的开发 - 工具类
相信每一个开发的框架都会有一个工具类,工具类的作用有很多,通常我会将最常用的方法放在工具类里 取得用户IP 取得网站根目录的物理路径 枚举相关 非法关键字检查 绝对路径改为相对路径 获取小数位(四舍五 ...
- pom.xml详情
这里借鉴一下csdn中的一个系列的博客: 第一篇:POM文件详解 第二篇:maven中的依赖作用范围 第三篇:maven中的可选依赖和依赖排除 第四篇:maven中的dependencies和depe ...