http://abc048.contest.atcoder.jp/tasks/arc064_b?lang=en

在vj里面用list模拟水过去了,然后感觉vj不靠谱,上atcoder交,果然tle

我的思路是这样的,first那个是没有必胜策略的,赢就是赢,随便拿哪一个都是赢。

所以只需要找到有多少个能拿的就行了。用list模拟下,TLE.

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <assert.h>
#define IOS ios::sync_with_stdio(false)
using namespace std;
#define inf (0x3f3f3f3f)
typedef long long int LL; #include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <bitset>
#include <list>
list<char>theList;
const int maxn = 1e5 + ;
char str[maxn];
void work() {
scanf("%s", str + );
int lenstr = strlen(str + );
for (int i = ; i <= lenstr; ++i) {
theList.push_back(str[i]);
}
// for (list<char> :: iterator it = theList.begin(); it != theList.end(); ++it) {
// cout << *it;
// }
int ans = ;
while (theList.size() > ) {
if (theList.size() == && theList.front() == theList.back()) break;
list<char> :: iterator itBegin = theList.begin();
itBegin++;
list<char> :: iterator itEnd = theList.end();
itEnd--;
list<char> :: iterator itBeginPre = theList.begin();
list<char> :: iterator itBeginNext = itBegin; itBeginNext++;
bool flag = false;
while (itBegin != itEnd) {
if (*itBeginPre == *itBeginNext) {
itBeginPre++;
itBegin++;
itBeginNext++;
} else {
theList.erase(itBegin);
flag = true;
break;
}
}
if (!flag) break;
ans++;
}
// cout << ans << endl;
if (ans & ) {
cout << "First" << endl;
} else cout << "Second" << endl;
} int main() {
#ifdef local
freopen("data.txt", "r", stdin);
// freopen("data.txt", "w", stdout);
#endif
work();
return ;
}

那么就需要快速找到有多少东西能拿,一般情况下,能拿的东西是lenstr - 2个,减去头和尾

博弈:

分为两种情况:

1、头和尾相等,这个时候能拿的东西次数 - 1,

2、头和尾不等,拿的东西次数不变

然后判断奇偶性就好。

那么死锁怎么办?就是像ababa

这里能拿的个数是0,但是按照上面的,是2.

看看基本的死锁是:aba,这样,那么再添加2个,可以形成新的死锁ababa

注意到添加元素的个数必定要是偶数,这个不影响奇偶性。

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <assert.h>
#define IOS ios::sync_with_stdio(false)
using namespace std;
#define inf (0x3f3f3f3f)
typedef long long int LL; #include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <bitset>
#include <list>
list<char>theList;
const int maxn = 1e5 + ;
char str[maxn];
void work() {
scanf("%s", str + );
int lenstr = strlen(str + );
lenstr -= ;
if (str[] == str[strlen(str + )]) lenstr--;
if (lenstr & ) {
cout << "First" << endl;
} else cout << "Second" << endl;
} int main() {
#ifdef local
freopen("data.txt", "r", stdin);
// freopen("data.txt", "w", stdout);
#endif
work();
return ;
}

AtCoder - 2153 An Ordinary Game list模拟 || 博弈的更多相关文章

  1. atcoder C - Snuke and Spells(模拟+思维)

    题目链接:http://agc017.contest.atcoder.jp/tasks/agc017_c 题解:就是简单的模拟一下就行.看一下代码就能理解 #include <iostream& ...

  2. 【AtCoder】ARC095 E - Symmetric Grid 模拟

    [题目]E - Symmetric Grid [题意]给定n*m的小写字母矩阵,求是否能通过若干行互换和列互换使得矩阵中心对称.n,m<=12. [算法]模拟 [题解]首先行列操作独立,如果已确 ...

  3. ACM-ICPC 2018 徐州赛区网络预赛 B BE, GE or NE 【模拟+博弈】

    题目:戳这里 题意:A和B博弈,三种操作分别是x:加a,y:减b,z:取相反数.当x或y或z为0,说明该操作不可取,数据保证至少有一个操作可取,给定一个区间(l,k)和原始数字m,如果A和B在n次操作 ...

  4. Atcoder Beginner Contest 115 D Christmas 模拟,递归 B

    D - Christmas Time limit : 2sec / Memory limit : 1024MB Score : 400 points Problem Statement In some ...

  5. AtCoder 杂题训练

    前言: 因为要普及了,今年没一等就可以退役去学文化课了,所以暑假把历年noip普及组都刷了一遍,离noip还有50+天,想弄点强化训练什么的. 想了想,就这些天学文化课之余有空就把AtCoder之前那 ...

  6. hdu_2147_kiki's game(博弈)

    题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=2147 题意:给你一个矩阵,从右上走到左下,每次只能向左或向下或向斜下走一格,先走到最后一格的会输,问k ...

  7. hdu-4023-博弈(模拟)

    Game Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others)Total Submis ...

  8. NOI前训练日记

    向别人学习一波,记点流水帐.17.5.29开坑. 5.29 早晨看了道据说是树状数组优化DP的题(hdu5542),然后脑补了一个复杂度500^3的meet in the middle.然后死T... ...

  9. NOIP 2020 游记

    第一次写比赛游记,请多多指教! I. 考前 由于最近参加了太多太多比赛了,所以没有敲模板题: 考前一周:主要是在做 AtCoder 的题和 xjoi 的模拟赛,相当于恶补了一些套路吧! 考前一天:上午 ...

随机推荐

  1. Understanding When to use RabbitMQ or Apache Kafka Kafka RabbitMQ 性能对比

    Understanding When to use RabbitMQ or Apache Kafka https://content.pivotal.io/rabbitmq/understanding ...

  2. (转)React Native 使用react-native-image-picker库实现图片上传功能

    react-native-image-picker作为一个集成相机和相册的功能的第三方库,因为其使用相对简单受到前端开发人员的喜爱. react-native-image-picker使用 首先,安装 ...

  3. Spark理论学习笔记(一)

    1.调度 分为FIFO和FAIR两种模式 创建调度池:sc.setLocalProperty("spark.scheduler.pool", "pool6") ...

  4. 修改STM32库函数中的晶振值

    STM32F407的库文件中默认晶振值为25MHz,若外接晶振8MHz,则需修改以下几个地方: 1)修改HSE_VALUE的值 将#define HSE_VALUE ((uint32_t)250000 ...

  5. mmwave

    毫米波(mmWave) 致力于支持5G应用创新开发,集成在BEEcube BEE7基带平台上的赛灵思256QAM毫米波调制解调器IP为宽带回程原型设计提供完整的开箱即用型解决方案 赛灵思公司 (NAS ...

  6. regmap使用介绍【转】

    本文转载自:http://blog.csdn.net/hellowxwworld/article/details/10737569 内核3.1引入一套新的API regmap,目的是提取出关于I2C ...

  7. (转)windows下的Expdp、Impdp使用

    1 .Expdp windows下导出截图示范 2.impdp windows下导入截图示范 Impdp system/eas directory=EASBAK dumpfile=stjt_10060 ...

  8. 并不对劲的bzoj1758:p4292:[WC2010]重建计划

    题目大意 \(n\)(\(n\leq10^5\))个点的一棵树,有边权\(w\),给定\(l,r\),求边数在\([l,r]\)中的路径的平均边权的最大值 题解 二分答案,判断时将边权变成\(w-mi ...

  9. SPOJ:Lexicographically Smallest(并查集&排序)

    Taplu and Abhishar loved playing scrabble. One day they thought of inventing a new game using alphab ...

  10. SPOJ:Another Version of Inversion(二维数组的逆序对)

    DCE Coders admins are way much geekier than they actually seem! Kartik has been following that tradi ...