https://vjudge.net/problem/Gym-100247A

题意:

每个绝地武士有三个能力值a,b,c,两个武士决斗时谁有两个值大于对方谁就是胜者(a和a比,b和b比,c和c比,所有武士的三个值都不相同),现在可以交换任意武士的三个能力值位置,问有些可以击败其余所有武士。

思路:

肯定是用自己最大的两个能力值去和别的武士的较低的两个能力值相比,两者皆大就能赢,因为要赢所有人,所以先对所有武士能力排序,这样每个武士的能力值都是递增的了,对每个位置的能力值都维护一个最大值(只要赢了最大值的那个,那肯定能赢其余所有人)和次大值(因为这个最大值可能是自己本身,此时就需要看次大值)。

 #include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn = +; int a[maxn][];
int mx[],smx[];
int q[maxn]; int main()
{
//freopen("in.txt","r",stdin);
int n;
scanf("%d",&n);
for(int i=;i<;i++) mx[i] = smx[i] = ;
for(int i=;i<=n;i++)
{
scanf("%d%d%d",&a[i][],&a[i][],&a[i][]);
sort(a[i],a[i]+);
smx[] = max(mx[],a[i][]);
if(smx[]>mx[]) swap(mx[],smx[]);
smx[] = max(mx[],a[i][]);
if(smx[]>mx[]) swap(mx[],smx[]);
} int ans = ;
for(int i=;i<=n;i++)
{
int t1 = mx[],t2 = mx[];
if(a[i][]==t1) t1 = smx[];
if(a[i][]==t2) t2 = smx[];
if(a[i][]>t1 && a[i][]>t2) q[ans++]=i;
}
printf("%d\n",ans);
for(int i=;i<ans;i++)
printf("%d%c",q[i],i==ans-?'\n':' ');
return ;
}

Gym 100247A The Power of the Dark Side的更多相关文章

  1. Gym - 101670J Punching Power(CTU Open Contest 2017 最大独立集)

    题目: The park management finally decided to install some popular boxing machines at various strategic ...

  2. gym102215题解

    A Rooms and Passages 题意 给n个数,从起点出发,一直往右走,遇到一个前面出现过其相反数的正数就停下,问对于每个起点都能走多少步. 分析 倒着递推,如果起点是正数,那么肯定可以走, ...

  3. MOD - Power Modulo Inverted(SPOJ3105) + Clever Y(POJ3243) + Hard Equation (Gym 101853G ) + EXBSGS

    思路: 前两题题面相同,代码也相同,就只贴一题的题面了.这三题的意思都是求A^X==B(mod P),P可以不是素数,EXBSGS板子题. SPOJ3105题目链接:https://www.spoj. ...

  4. Gym - 101670H Dark Ride with Monsters(CTU Open Contest 2017 贪心)

    题目: A narrow gauge train drives the visitors through the sequence of chambers in the Dark Ride attra ...

  5. Gym 102263 ArabellaCPC 2019 J - Thanos Power (DP,数学)

    题意:有一个整数\(n\),每次可以对加\(10^x\)或减\(10^x\),问最少操作多少次能得到\(n\). 题解:对于某一位上的数,我们可以从\(0\)加几次得到,或者从前一位减几次得到.所以对 ...

  6. ACM: Gym 100935G Board Game - DFS暴力搜索

    Board Game Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u  Gym 100 ...

  7. Codeforces Gym 100187K K. Perpetuum Mobile 构造

    K. Perpetuum Mobile Time Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/pro ...

  8. codeforces Gym 100187H H. Mysterious Photos 水题

    H. Mysterious Photos Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/p ...

  9. Codeforces gym 100685 F. Flood bfs

    F. FloodTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100685/problem/F Desc ...

随机推荐

  1. nodejs之pm2自动重启服务

    pm2 start xxx #启动服务器 pm2 list #查看运行状态 pm2 logs #查看日志 pm2 restart xxx #重启应用 pm2 stop xxx #停止应用 监听修改,并 ...

  2. Fabric架构:抽象的逻辑架构与实际的运行时架构

    Fabric从1.X开始,在扩展性及安全性上面有了大大的提升,且新增了诸多的新特性: 多通道:支持多通道,提高隔离安全性. 可拔插的组件:支持共识组件.权限管理组件等可拔插功能. 账本数据可被存储为多 ...

  3. js中利用cookie实现记住密码功能

    在登录界面添加记住密码功能,代码如下: //设置cookie var passKey = '4c05c54d952b11e691d76c0b843ea7f9'; function setCookie( ...

  4. linux git 报错提示 fatal: 'origin' does not appear to be a git repository 解决办法

    输入: git pull origin master git报错提示 fatal: 'origin' does not appear to be a git repository fatal: Cou ...

  5. ztree实现表格风格的树状结构

    zTree官方api: http://www.treejs.cn/v3/api.php 原理很简单:利用zTree的addDiyDom方法,自定义每个DOM节点,在原来的节点后面加一些div,再利用c ...

  6. spring List,Set,Map,Properties,array的配置文件注入方式

    虽然不多,但是有时候在实现的时候,我们还是希望某些参数或者属性通过集合()的方式注入进来,比如配置表参数列表,addresslist,亦或是三方库等等.因为这种改动不是很多,经常一时想不起来,今天做个 ...

  7. Java 中断异常的正确处理方式

    处理InterruptedException 这个故事可能很熟悉:你正在写一个测试程序,你需要暂停某个线程一段时间,所以你调用 Thread.sleep().然后编译器或 IDE 就会抱怨说 Inte ...

  8. 10: vue-router和单文件组件

    1.1 vue-router路由基本使用 官网: https://router.vuejs.org/zh/api/#router-link 1.安装vue-router bower info vue- ...

  9. Centos7编译安装zabbix-4.0.1

    架构组合:nginx1.9.10+php7.0.32+mysql5.7.22+zabbix4.0.1 nginx1.9.10 先装依赖 openssl-1.1.0f tar zxvf openssl- ...

  10. Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) Problem A - B

    Array of integers is unimodal, if: it is strictly increasing in the beginning; after that it is cons ...