• 题解 CF1190B 【Tokitsukaze, CSL and Stone Game】


    思路:

    首先题目告诉我们,一次只能删去一个石子。当然有翻译时会注意,但是看英文题时总是容易忽略。。

    先排序。

    然后,你会发现,有些情况是一开始就输的,具体情况如下:

    1. 有两个 两个相等非零数。(a[x] == a[x+1], a[y] == a[y+1], x != y)
    2. 有两个零。 (a[x] == a[y] == 0)
    3. 有一个(a[x] + 1 == a[x+1] == a[x+2]),此时也直接输。

    判完后,可以证明,无论他们怎么取,只要不使自己输,都会形成类似序列{0,1,2,3,...}的情况。

    此时,只要判断一下石子总数减去最终状态的奇偶性即可。

    代码:

    #include<bits/stdc++.h>
    #define repeat(a,b,c,g) for (int a=b,abck=(g>=0?1:-1);abck*(a)<=abck*(c);a+=g)
    using namespace std;
     
    int a[110000];
    int n;
    char lost[] = "cslnb";
    char win[] = "sjfnb";
    long long tot = 0;
    long long ans = 0;
    int ptr = 0;
    int main()
    {
    	cin >> n;
    	for (int i=1;i<=n;i++)
    		cin >> a[i];
    	sort(a+1,a+n+1);
    	for (int i=2;i<=n;i++)
    	{
    		if (a[i-1] == 0 && a[i] == 0)
    			cout << lost, exit(0);
    		if (a[i-1] == a[i]) ptr++;
    		if (a[i-1] == a[i] && i > 2 && a[i-2] + 1 >= a[i])
     		cout << lost, exit(0);
    		//Die at first
    	}
    	if (ptr > 1) cout << lost << endl,exit(0);
    	for (int i=1;i<=n;i++)
    		tot += a[i], tot -= (i-1);
    	if (tot % 2 == 0)
    		cout << lost << endl;
    	else cout << win << endl;
    }
    
  • 相关阅读:
    window.setInterval
    用gcc/g++编译winsock程序
    Yii 三表关联 角色表、角色权限连接表、权限表
    访问CGI程序时不添加 /cgi-bin/ 目录也可访问
    Linux 目录递归赋权,解决 Linux权限不够
    Linux 下用C语言连接 sqlite
    ORACLE中添加删除主键
    Linux 杀死进程
    Oracle 查询重复数据
    exlipse php 插件安装地址
  • 原文地址:https://www.cnblogs.com/dgklr/p/11187705.html
Copyright © 2020-2023  润新知