题目:
这题我wa到想死了,,,崩溃的心都有了。。。。。。。
思路:
遇到 1 必胜态就会跳转,所以,你的任务其实就是统计从i开始后开头有多少个1,但是你不能用两循环(会T),,,所以,, ,你可以用一个bool型函数从数组的后面对 值为 1 的数进行跳转,然后输出就可以了(全是1的情况和全部不是 1 的情况要分开。。。。)
我被卡的几组样例是:
5
1 1 1 1 2
5
2 1 1 1 1
5
1 1 2 1 1
5
1 2 1 1 1
5
1 1 1 1 1
每一组样例我都wa了一次,最后绿了的时候我,,,,,快~~~·枯了
#include<stdio.h>
#include<iostream>
#include<map>
#include<algorithm>
#include<cstring>
#include<string.h>
#include<math.h>
using namespace std;
typedef long long ll;
#define MAXN 100005
#define INF 0x3f3f3f3f//将近int类型最大数的一半,而且乘2不会爆int
int a[MAXN*2];
bool s[MAXN*2];
int main()
{
int n, sum=0;
cin >> n;
memset(s, true, sizeof(s));
bool ans = true, tem = true;
for(int i=1; i<=n; ++i)
{
scanf("%d", &a[i]);
a[n+i] = a[i];
if(a[i] == 1)
{
ans = false;
sum++;
}
}
if(ans)
for(int i=0; i<n; ++i)
cout << "First\n";
else
{
if(sum == n)
{
if(sum%2)
for(int i=0; i<n; ++i)
cout << "First\n";
else
for(int i=0; i<n; ++i)
cout << "Second\n";
}
else
{
for(int i=2*n; i>0; --i)
{
if(a[i] == 1)
s[i] = !s[i+1];
}
for(int i=1; i<=n; ++i)
if(s[i] == true)
cout << "First\n";
else
cout << "Second\n";
}
}
return 0;
}
题解是这样的: