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元素,我们有可能既用到了 ...
随机推荐
- 将PHP数组输出为HTML表格
1. [代码][PHP]代码 <?phpclass xtable{ private $tit,$arr,$fons,$sextra; public function __con ...
- static静态数据的初始化
package com.demo.book; public class StaticInitialization { static Table table = new Table(); static ...
- Power Strings--KMP
https://cn.vjudge.net/problem/POJ-2406 上面是比赛链接. 题目意思很明确,问最多是多少个子串连接而成的? 这个需要用到KMP,很好的理解KMP的Next数组.Ne ...
- Tomcat 安装之后,双击Tomcat.exe,无法运行成功,怎么办?
Log形式多种多样,有的时候跟下面一样: 首先的解决方案就是:修改server.xml中所有的端口,因为不只8080端口可能被占用! 我在出问题的时候就修改8080端口.结果死活运行不了,纠结一些时间 ...
- 洛谷 1079 Vigenère 密码——模拟水题
题目:https://www.luogu.org/problemnew/show/P1079 大水题. #include<iostream> #include<cstdio> ...
- eclipse的工程里的*.properties文件默认以unicode的编码形式显示
今天发现导入eclipse的工程里的*.properties文件无法显示中文,是unicode的编码形式显示的. 原因是Eclipse的.properties文件的默认编码为iso-8859-1. 选 ...
- ceph之ceph-client安装
1.安装ceph-client ceph-deploy install ceph-client 2.创建块设备 [root@mon1 ~]# rbd create test1 --image-form ...
- CodeForces 1110H. Modest Substrings
题目简述:给定$1 \leq l \leq r \leq 10^{800}$,求一个长度为$n \leq 2000$的数字串$s$,其含有最多的[好]子串.一个串$s$是[好]的,如果将其看做数字时无 ...
- error:: undefined reference to symbol '__glewBufferSubData' 未定义的引用 以及 error: main.o: undefined reference to symbol 'glTexImage2D'
在把DSO移植到QT工程中,出现了 /usr/bin/ld: KeyFrameDisplay.o: undefined reference to symbol '__glewBufferSubData ...
- 20个Flutter实例视频教程-第12节: 流式布局 模拟添加照片效果
视频地址: https://www.bilibili.com/video/av39709290/?p=12 博客地址: https://jspang.com/post/flutterDemo.html ...