The Weakest Sith
http://codeforces.com/gym/101149/problem/F
题目要输出最丑陋的衣服。所以每件衣服都要和其他衣服比一次。
但是注意到,能赢一件衣服的衣服,就算是好衣服了。
那么,可以选1做起始点,然后向后比较,如果后面的能赢比较点,那么这件就是好衣服了。
如果不能,那么证明起始点那件衣服是好衣服。当前这件衣服不确定,所以就重新选这件衣服做起吃点,去比较。
有可能会1赢7,7赢8但是8赢2这样,就是说可能要往前比较一次。
所以把数组写两次就可以了。
- #include <cstdio>
- #include <cstdlib>
- #include <cstring>
- #include <cmath>
- #include <algorithm>
- #define IOS ios::sync_with_stdio(false)
- using namespace std;
- #define inf (0x3f3f3f3f)
- typedef long long int LL;
- #include <iostream>
- #include <sstream>
- #include <vector>
- #include <set>
- #include <map>
- #include <queue>
- #include <string>
- const int maxn = 2e5 + ;
- struct node {
- int a, b, c;
- bool operator == (const struct node & rhs) const {
- return a == rhs.a && b == rhs.b && c == rhs.c;
- }
- }arr[maxn * ];
- bool iswin[maxn * ];
- bool check(struct node a, struct node b) { //b打赢a
- if (b.a > a.a && b.b > a.b) return true;
- if (b.a > a.a && b.c > a.c) return true;
- if (b.b > a.b && b.c > a.c) return true;
- return false;
- }
- void work() {
- int n;
- cin >> n;
- for (int i = ; i <= n; ++i) {
- cin >> arr[i].a >> arr[i].b >> arr[i].c;
- arr[i + n] = arr[i];
- }
- int ans = ;
- struct node now = arr[];
- int id = ;
- for (int i = ; i <= * n; ++i) {
- if (now == arr[i]) continue;
- if (check(now, arr[i])) {
- iswin[i] = true;
- } else {
- iswin[id] = true;
- now = arr[i];
- id = i;
- }
- }
- for (int i = ; i <= n; ++i) {
- ans += iswin[i] == false;
- }
- cout << ans << endl;
- for (int i = ; i <= n; ++i) {
- if (iswin[i] == false) {
- cout << i << endl;
- }
- }
- }
- int main() {
- #ifdef local
- freopen("data.txt","r",stdin);
- #endif
- IOS;
- work();
- return ;
- }
The Weakest Sith的更多相关文章
- 排序构造 GYM 101149 F - The Weakest Sith
题目链接:http://codeforces.com/gym/101149/my 题目大意:给你n个人,他们有成绩a,b,c.一个人如果两门课比另外一个人高,那么这个人就比那个人厉害.问,是否存在一个 ...
- Educational Codeforces Round 13 E. Another Sith Tournament 概率dp+状压
题目链接: 题目 E. Another Sith Tournament time limit per test2.5 seconds memory limit per test256 megabyte ...
- Educational Codeforces Round 13 E. Another Sith Tournament 状压dp
E. Another Sith Tournament 题目连接: http://www.codeforces.com/contest/678/problem/E Description The rul ...
- Codeforces 678E. Another Sith Tournament(概率DP,状压)
Codeforces 678E. Another Sith Tournament 题意: n(n<=18)个人打擂台赛,给定任意两人对决的胜负概率,比赛规则:可指定一人作为最开始的擂主,每次可指 ...
- codeforces 678E Another Sith Tournament 概率dp
奉上官方题解 然后直接写的记忆化搜索 #include <cstdio> #include <iostream> #include <ctime> #include ...
- Codeforces 678E(Another Sith Tournament)
题目链接:传送门 题目大意:有n个人决斗(n<=18),每两个人之间都有一定几率杀死对方,一次进行一次决斗,胜利者成为擂主继续接受决斗直到只剩下一个人,你是一号,问你最大有多大几率存活到最后. ...
- Codeforces 678E Another Sith Tournament 状压DP
题意: 有\(n(n \leq 18)\)个人打擂台赛,编号从\(1\)到\(n\),主角是\(1\)号. 一开始主角先选一个擂主,和一个打擂的人. 两个人之中胜的人留下来当擂主等主角决定下一个人打擂 ...
- 十个免费的web应用安全检测工具
Websites are getting more and more complex everyday and there are almost no static websites being bu ...
- CSS:CSS样式表及选择器优先级总结
我们在写网页的时候经常会遇到同一个HTML文件,使用了外部样式.内部样式以及内联样式,那么如果发生冲突时浏览器是怎么抉择的呢? 也会遇到这样的情况,在样式表中,对同一个HTML元素,我们有可能既用到了 ...
随机推荐
- dtd文件中写的引用实体被xml文件引用后无法在浏览器中显示的问题
解决方案:把dtd文件由被xml文件外部引用改成被xml文件内部引用. 例子: 1.xml文件: <?xml version="1.0" encoding="UTF ...
- RTree算法Java实现 JSI RTree Library的调用实例 标签:jsi-rtree-library
1. [代码]jsi-rtree-library /** * */package com.mycompany.project; //package net.sourceforge.jsi.examp ...
- linux应用之mysql数据库指定版本的yum安装(centos)
A Quick Guide to Using the MySQL Yum Repository Abstract The MySQL Yum repository provides RPM packa ...
- linux系统配置之PATH环境变量的设置(centos)
Centos系统下修改环境变量PATH路径的方法 电脑脑中必不可少的就是操作系统.而Linux的发展非常迅速,有赶超微软的趋势.这里介绍Linux的知识,让你学好应用Linux系统.比如要把/etc/ ...
- Java面向对象的三大特征详解
一.封装(Encapsulation) 封装也称信息隐藏,是指利用抽象数据类型把数据和基于数据的操作封装起来,使其成为一个不可分割的整体,数据隐藏在抽象数据内部,尽可能的隐藏数据细节,只保 ...
- 最新版ADT(Build: v22.6.2)总是引用appcompat_v7的问题
昨天在ADT Manager里更新了一些组件,结果ADT不支持.索性直接下载了最新的ADT.但是发现无论创建什么类型的应用(无论支持的最低API是多少,或者是不是用模板),都会在创建应用的同时创建一个 ...
- 洛谷P4092树——并查集
题目:https://www.luogu.org/problemnew/show/P4092 利用并查集,倒序离线,那么从倒序来看被撤销标记的点就再也不会被标记,所以用并查集跳过: 莫名其妙的WA,调 ...
- HDU1171(01背包均分问题)
Big Event in HDU Time Limit:5000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u De ...
- js格式
/** * Created by admin on 2017/9/22. */ // 分号后不要再有多余的空格 var name = "North"; var name = &qu ...
- bzoj4833
$数论$ $这个题已经忘了怎么做了,也不想知道了,只记得看了3个小时$ $对于有gcd(f_i, f_j) = f_{gcd(i, j)}性质的数列,以下结论适用$ #include<bits/ ...