Gym 100247A The Power of the Dark Side
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的更多相关文章
- Gym - 101670J Punching Power(CTU Open Contest 2017 最大独立集)
题目: The park management finally decided to install some popular boxing machines at various strategic ...
- gym102215题解
A Rooms and Passages 题意 给n个数,从起点出发,一直往右走,遇到一个前面出现过其相反数的正数就停下,问对于每个起点都能走多少步. 分析 倒着递推,如果起点是正数,那么肯定可以走, ...
- MOD - Power Modulo Inverted(SPOJ3105) + Clever Y(POJ3243) + Hard Equation (Gym 101853G ) + EXBSGS
思路: 前两题题面相同,代码也相同,就只贴一题的题面了.这三题的意思都是求A^X==B(mod P),P可以不是素数,EXBSGS板子题. SPOJ3105题目链接:https://www.spoj. ...
- 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 ...
- Gym 102263 ArabellaCPC 2019 J - Thanos Power (DP,数学)
题意:有一个整数\(n\),每次可以对加\(10^x\)或减\(10^x\),问最少操作多少次能得到\(n\). 题解:对于某一位上的数,我们可以从\(0\)加几次得到,或者从前一位减几次得到.所以对 ...
- ACM: Gym 100935G Board Game - DFS暴力搜索
Board Game Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Gym 100 ...
- Codeforces Gym 100187K K. Perpetuum Mobile 构造
K. Perpetuum Mobile Time Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/pro ...
- codeforces Gym 100187H H. Mysterious Photos 水题
H. Mysterious Photos Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/p ...
- Codeforces gym 100685 F. Flood bfs
F. FloodTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100685/problem/F Desc ...
随机推荐
- leaflet:调用arcgis切片地图服务
var mymap = L.map('mapid').setView([31.59, 120.29], 7); L.tileLayer('http://map.geoq.cn/ArcGIS/rest/ ...
- 74.Java异常处理机制
package testDate; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IO ...
- Codeforce 697A - Pineapple Incident
Ted has a pineapple. This pineapple is able to bark like a bulldog! At time t (in seconds) it barks ...
- Hybrid App中原生页面 VS H5页面(分享)
本文部分转自 http://www.jianshu.com/p/00ff5664e000 现有3类主流APP,分别为:Web App.Hybrid App(混合模式移动应用,Hybrid有“混合的” ...
- Linux下的Jmeter运行测试
本文主要介绍Jmeter脚本如何在Linux通过no GUI的方式运行.总共分三部分: 1.Linux下JDK的安装及环境变量的配置 2.Linux下Jmeter的安装及环境变量的配置 3.运行结果的 ...
- SpringMVC之JSON交互
#什么是json? json是一种用于储存数据格式,是js脚本语言的子集. #json的作用? 它可以传递对象.数组等数据结构.如果是单个数据,则要用数组,不用对象,因为对象都是键值对的 方式去存储, ...
- How to click on a point on an HTML5 canvas in Python selenium webdriver
https://stackoverflow.com/questions/29624949/how-to-click-on-a-point-on-an-html5-canvas-in-python-se ...
- ionic + angular + cordova, 打造专属自己的App!
ionic 学习地址:http://ionicframework.com/ ionic 好处: ionic serve --lab 预览平台间的差异化 sass 提 ...
- ldap集成rabbitmq
rabbitmq版本: 3.7.4 rabbitmq支持ldap需要开启插件: rabbitmq-plugins enable rabbitmq_auth_backend_ldap rab ...
- 牛客网数据库SQL实战(1-5)
1.查找最晚入职员工的所有信息 CREATE TABLE `employees` ( `emp_no` int(11) NOT NULL, `birth_date` date NOT NULL, `f ...