Codeforces Roundd #573 (Div. 2)
D. Tokitsukaze, CSL and Stone Game
题意:有n堆石头,每人每次只能去一颗石子,若轮到当前人没任何一堆石子可以取或当前人取到后剩下有俩堆石子个数相同则当前人输;
给定石子序列。
分析:1、若有类似“2 3 3 ”则后手胜,因为有这个序列就必须在这个序列中去石子(因为如果在这个序列以外取子,则会导致输的后者情况),但在这个序列中取不到可解情况,所以该状态为必败态;
2、若序列中有俩对相同的石子,则后手胜;
3、除1、2情况外就把利用sum+起来,每个加就+a[i]-(i+1) 为了把他提到前面他不能再动的最优状态(因为俩者都采取最优策略!!!)
- #include<bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- ll a[];
- int main(){
- int n;
- ll sum=;
- cin>>n;
- for(int i=;i<=n;i++)
- cin>>a[i],sum+=a[i];
- sort(a+,a++n);
- int countt=;
- for(int i=;i<n;i++){
- if(a[i]==a[i+]){
- if(a[i]==||(i>&&a[i-]+==a[i])||++countt>){
- return puts("cslnb"),;
- }
- }
- }
- sum-=n*(n-)/;
- if(sum%==)
- puts("cslnb");
- else
- puts("sjfnb");
- return ;
- }
F. Tokitsukaze and Strange Rectangle
分析:1、对于每一个点来说,他对问题的贡献为“对于某个点(图中的红点),包含这个点的区间个数是(a区间点个数+1)*(b区间点个数+1)”因为涉及区间个数,所以考虑用树状数组求;
2、问题给的x和y1e9,所以要离散化处理一下;
3、离散化后的坐标是紧挨在一起的!!!!
4、对于分析第1步的a区间即为不包含当前点的左区间的点的个数,b区间则为不包含当前点的右区间(为了避免重复计算,这个区间的右端点应为当前点的下一点-1);
5、至于分析第1步为啥都要+1,是为了: 点的个数加1个位置可以作为区间端点的取值;
- #include<bits/stdc++.h>
- using namespace std;
- const int M=2e5+;
- typedef long long ll;
- int bit[M],x[M],y[M],vis[M];
- vector<int>tx,ty,zuobiao[M];
- void add(int xx){
- while(xx<M)
- bit[xx]++,xx+=xx&-xx;
- }
- int sum(int xx){
- int ans=;
- while(xx)
- ans+=bit[xx],xx-=xx&-xx;
- return ans;
- }
- int main(){
- int n;
- scanf("%d",&n);
- for(int i=;i<=n;i++){
- scanf("%d%d",&x[i],&y[i]);
- tx.push_back(x[i]);
- ty.push_back(y[i]);
- }
- sort(tx.begin(),tx.end());
- sort(ty.begin(),ty.end());
- for(int i=;i<=n;i++){
- x[i]=lower_bound(tx.begin(),tx.end(),x[i])-tx.begin()+;
- y[i]=lower_bound(ty.begin(),ty.end(),y[i])-ty.begin()+;
- zuobiao[y[i]].push_back(x[i]);
- }
- ll ans=;
- for(int i=M-;i>=;i--){
- if(zuobiao[i].size()==)
- continue;
- sort(zuobiao[i].begin(),zuobiao[i].end());
- for(int j=;j<zuobiao[i].size();j++){
- int xx=zuobiao[i][j];
- if(!vis[xx])
- add(xx),vis[xx]=;
- int l=sum(xx-);
- int r;
- if(j+==zuobiao[i].size())
- r=sum(M-)-sum(xx);
- else
- r=sum(zuobiao[i][j+]-)-sum(xx);
- ans+=(l+)*1ll*(r+);
- }
- }
- printf("%I64d\n",ans);
- return ;
- }
Codeforces Roundd #573 (Div. 2)的更多相关文章
- Codeforces Round #573 (Div. 1) 差F
Codeforces Round #573 (Div. 1) E 题意:二维平面上有 n 个点,你可以放至多 m 条直线使得 (0,0) 与每个点的连线至少与一条直线相交.求原点与所有直线的距离最小值 ...
- Codeforces Round 573 (Div.1) 题解
这场怎么说呢……有喜有悲吧. 开场先秒了 A.看到 B,感觉有点意思,WA 了 2 发后也过了. 此时还在 rk 前 200. 开 C,一看就不可做.跟榜,切 D 人数是 C 的两倍. 开 D.一眼感 ...
- Codeforces Round #573 (Div. 2) Tokitsukaze and Mahjong 水题
B. Tokitsukaze and Mahjong time limit per test1 second memory limit per test256 megabytes Tokitsukaz ...
- Codeforces Round #573 (Div. 1)
Preface 军训终于结束了回来补一补之前的坑发现很多题目题意都忘记了 这场感觉难度适中,F由于智力不够所以弃了,E的话石乐志看了官方英文题解才发现自己已经胡了一大半就差实现了233 水平下降严重. ...
- Codeforces Round #573 (Div. 2) D. Tokitsukaze, CSL and Stone Game (博弈,思维)
D. Tokitsukaze, CSL and Stone Game time limit per test1 second memory limit per test256 megabytes in ...
- Codeforces Round #573 (Div. 2) E. Tokitsukaze and Duel (博弈)
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- Codeforces Round #573 (Div. 2)
A:Tokitsukaze and Enhancement 当时看错条件了..以为A>C>B>D.就胡写了判断条件. #include<bits/stdc++.h> us ...
- Codeforces Round #573 (Div. 2) D题题解
一.题目 Tokitsukaze, CSL and Stone Game Tokitsukaze和CSL正在玩一些石头游戏. 一开始,有n堆的石头,第i堆石头数记为 \(a_i\),两人轮 ...
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
随机推荐
- POJ 3659 再谈树形DP
Cell Phone Network Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5325 Accepted: 188 ...
- Vmware 困惑点记录和解释
个人理解,如果有不同见解,麻烦请留言,一起进行探讨: DRS和HA是两个独立的功能. 准入控制只是保障有资源打开故障后迁移来的虚拟机,就算自身已经超过切换的阈值了,HA也是可以迁移过去的. 虚拟机允许 ...
- VUE,index key v-for
列表渲染语法 v-forv-for 循环对象 <article v-for="(item, key, index) of info">{{item}} {{key}} ...
- JavaScript—面向对象 贪吃蛇_3 蛇对象
蛇对象 function Snake(element) { this.width = 20 this.height = 20 //蛇身 位置 颜色 this.body = [ {x: 6, y: 4, ...
- What is the maximum length of a URL in different browsers?
https://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers ...
- subprocess.Popen stdout重定向内容实时获取
python 打开一个新进程执行系统命令, test 执行完才能获取返回, test1 实时获取返回结果 import subprocess def test(cmd): p = subprocess ...
- 14)载入png图片
1)之前在窗口中载入图片 一般都是bmp的 但是 我想从网上下一些图片,这些图片可能是png的 2)那么就有了下面的操作 3)png图片可以直接做成透明的. 4)首先是创建窗口的基本代码: #i ...
- PAT Advanced 1050 String Subtraction (20) [Hash散列]
题目 Given two strings S1 and S2, S = S1 – S2 is defined to be the remaining string afer taking all th ...
- 新年在家学java之基础篇-高级类的特性
继承 extends 子类的共性代码都是继承自父类的,每个子类只要写自己特有的代码 class 子类 extends 父类 继承提高了代码的复用性,提供了多态的前提,但是不要为了某个功能去继承 子类不 ...
- FastReport 使用入门
FastReport 是微软开发的一款快速报表工具,使用起来非常方便简单 最关键的是快捷. 下面介绍一下 Fastreport在项目中的使用. 下图为其中一个效果图 首先 打开FastReport ...