D. Tokitsukaze, CSL and Stone Game

题意:有n堆石头,每人每次只能去一颗石子,若轮到当前人没任何一堆石子可以取或当前人取到后剩下有俩堆石子个数相同则当前人输;

给定石子序列。

分析:1、若有类似“2 3 3 ”则后手胜,因为有这个序列就必须在这个序列中去石子(因为如果在这个序列以外取子,则会导致输的后者情况),但在这个序列中取不到可解情况,所以该状态为必败态;

    2、若序列中有俩对相同的石子,则后手胜;

   3、除1、2情况外就把利用sum+起来,每个加就+a[i]-(i+1)    为了把他提到前面他不能再动的最优状态(因为俩者都采取最优策略!!!)

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. ll a[];
  5. int main(){
  6. int n;
  7. ll sum=;
  8. cin>>n;
  9.  
  10. for(int i=;i<=n;i++)
  11. cin>>a[i],sum+=a[i];
  12. sort(a+,a++n);
  13. int countt=;
  14. for(int i=;i<n;i++){
  15. if(a[i]==a[i+]){
  16. if(a[i]==||(i>&&a[i-]+==a[i])||++countt>){
  17. return puts("cslnb"),;
  18. }
  19. }
  20. }
  21. sum-=n*(n-)/;
  22. if(sum%==)
  23. puts("cslnb");
  24. else
  25. puts("sjfnb");
  26. return ;
  27.  
  28. }

F. Tokitsukaze and Strange Rectangle

分析:1、对于每一个点来说,他对问题的贡献为“对于某个点(图中的红点),包含这个点的区间个数是(a区间点个数+1)*(b区间点个数+1)”因为涉及区间个数,所以考虑用树状数组求; 

   2、问题给的x和y1e9,所以要离散化处理一下;

   3、离散化后的坐标是紧挨在一起的!!!!

   4、对于分析第1步的a区间即为不包含当前点的左区间的点的个数,b区间则为不包含当前点的右区间(为了避免重复计算,这个区间的右端点应为当前点的下一点-1);

     5、至于分析第1步为啥都要+1,是为了:    点的个数加1个位置可以作为区间端点的取值;

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. const int M=2e5+;
  4. typedef long long ll;
  5. int bit[M],x[M],y[M],vis[M];
  6. vector<int>tx,ty,zuobiao[M];
  7. void add(int xx){
  8. while(xx<M)
  9. bit[xx]++,xx+=xx&-xx;
  10. }
  11. int sum(int xx){
  12. int ans=;
  13. while(xx)
  14. ans+=bit[xx],xx-=xx&-xx;
  15. return ans;
  16. }
  17. int main(){
  18. int n;
  19. scanf("%d",&n);
  20. for(int i=;i<=n;i++){
  21. scanf("%d%d",&x[i],&y[i]);
  22. tx.push_back(x[i]);
  23. ty.push_back(y[i]);
  24. }
  25. sort(tx.begin(),tx.end());
  26. sort(ty.begin(),ty.end());
  27. for(int i=;i<=n;i++){
  28. x[i]=lower_bound(tx.begin(),tx.end(),x[i])-tx.begin()+;
  29. y[i]=lower_bound(ty.begin(),ty.end(),y[i])-ty.begin()+;
  30. zuobiao[y[i]].push_back(x[i]);
  31. }
  32. ll ans=;
  33. for(int i=M-;i>=;i--){
  34. if(zuobiao[i].size()==)
  35. continue;
  36. sort(zuobiao[i].begin(),zuobiao[i].end());
  37. for(int j=;j<zuobiao[i].size();j++){
  38. int xx=zuobiao[i][j];
  39.  
  40. if(!vis[xx])
  41. add(xx),vis[xx]=;
  42. int l=sum(xx-);
  43. int r;
  44. if(j+==zuobiao[i].size())
  45. r=sum(M-)-sum(xx);
  46. else
  47. r=sum(zuobiao[i][j+]-)-sum(xx);
  48. ans+=(l+)*1ll*(r+);
  49. }
  50. }
  51. printf("%I64d\n",ans);
  52. return ;
  53. }

Codeforces Roundd #573 (Div. 2)的更多相关文章

  1. Codeforces Round #573 (Div. 1) 差F

    Codeforces Round #573 (Div. 1) E 题意:二维平面上有 n 个点,你可以放至多 m 条直线使得 (0,0) 与每个点的连线至少与一条直线相交.求原点与所有直线的距离最小值 ...

  2. Codeforces Round 573 (Div.1) 题解

    这场怎么说呢……有喜有悲吧. 开场先秒了 A.看到 B,感觉有点意思,WA 了 2 发后也过了. 此时还在 rk 前 200. 开 C,一看就不可做.跟榜,切 D 人数是 C 的两倍. 开 D.一眼感 ...

  3. Codeforces Round #573 (Div. 2) Tokitsukaze and Mahjong 水题

    B. Tokitsukaze and Mahjong time limit per test1 second memory limit per test256 megabytes Tokitsukaz ...

  4. Codeforces Round #573 (Div. 1)

    Preface 军训终于结束了回来补一补之前的坑发现很多题目题意都忘记了 这场感觉难度适中,F由于智力不够所以弃了,E的话石乐志看了官方英文题解才发现自己已经胡了一大半就差实现了233 水平下降严重. ...

  5. 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 ...

  6. Codeforces Round #573 (Div. 2) E. Tokitsukaze and Duel (博弈)

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  7. Codeforces Round #573 (Div. 2)

    A:Tokitsukaze and Enhancement 当时看错条件了..以为A>C>B>D.就胡写了判断条件. #include<bits/stdc++.h> us ...

  8. Codeforces Round #573 (Div. 2) D题题解

    一.题目 ​ Tokitsukaze, CSL and Stone Game ​ Tokitsukaze和CSL正在玩一些石头游戏. ​ 一开始,有n堆的石头,第i堆石头数记为 \(a_i\),两人轮 ...

  9. 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 ...

随机推荐

  1. POJ 3659 再谈树形DP

    Cell Phone Network Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5325   Accepted: 188 ...

  2. Vmware 困惑点记录和解释

    个人理解,如果有不同见解,麻烦请留言,一起进行探讨: DRS和HA是两个独立的功能. 准入控制只是保障有资源打开故障后迁移来的虚拟机,就算自身已经超过切换的阈值了,HA也是可以迁移过去的. 虚拟机允许 ...

  3. VUE,index key v-for

    列表渲染语法  v-forv-for 循环对象 <article v-for="(item, key, index) of info">{{item}} {{key}} ...

  4. JavaScript—面向对象 贪吃蛇_3 蛇对象

    蛇对象 function Snake(element) { this.width = 20 this.height = 20 //蛇身 位置 颜色 this.body = [ {x: 6, y: 4, ...

  5. 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 ...

  6. subprocess.Popen stdout重定向内容实时获取

    python 打开一个新进程执行系统命令, test 执行完才能获取返回, test1 实时获取返回结果 import subprocess def test(cmd): p = subprocess ...

  7. 14)载入png图片

    1)之前在窗口中载入图片  一般都是bmp的  但是  我想从网上下一些图片,这些图片可能是png的 2)那么就有了下面的操作 3)png图片可以直接做成透明的. 4)首先是创建窗口的基本代码: #i ...

  8. 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 ...

  9. 新年在家学java之基础篇-高级类的特性

    继承 extends 子类的共性代码都是继承自父类的,每个子类只要写自己特有的代码 class 子类 extends 父类 继承提高了代码的复用性,提供了多态的前提,但是不要为了某个功能去继承 子类不 ...

  10. FastReport 使用入门

    FastReport  是微软开发的一款快速报表工具,使用起来非常方便简单  最关键的是快捷. 下面介绍一下 Fastreport在项目中的使用. 下图为其中一个效果图 首先 打开FastReport ...