Codeforces Gym 100431D Bubble Sort 水题乱搞
原题链接:http://codeforces.com/gym/100431/attachments/download/2421/20092010-winter-petrozavodsk-camp-andrew-stankevich-contest-37-asc-37-en.pdf
题意
神奇的电路可以通过比较器来实现冒泡。
题解
倒着往回考虑,搞搞就好。
代码
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAX_N 222
using namespace std; int n; int a[MAX_N][MAX_N];
int x[MAX_N]; int tim[MAX_N][MAX_N]; int main() {
freopen("bubble.in", "r", stdin);
freopen("bubble.out", "w", stdout);
tim[][] = ;
scanf("%d", &n);
for (int i = ; i < n; i++)x[i] = i;
for (int i = ; i < n - ; i++)
for (int j = ; j <= i; j++)
scanf("%d", &a[i][j]);
for (int i = ; i < n - ; i++)
for (int j = ; j <= i; j++)
tim[i + ][j] = tim[i][j] + , tim[i + ][j + ] = tim[i][j] - ;
for (int now = tim[n - ][n - ]; now <= tim[n - ][]; now++) {
for (int i = ; i < n - ; i++)
for (int j = ; j <= i; j++)
if (tim[i][j] == now) {
int u = i, v = i + ;
if (x[u] > x[v]) {
printf("NO\n");
return ;
}
if (a[i][j])swap(x[u], x[v]);
}
}
printf("YES\n");
for (int i = ; i < n; i++)
printf("%d ", x[i] + );
return ;
}
Codeforces Gym 100431D Bubble Sort 水题乱搞的更多相关文章
- Codeforces Gym 100286G Giant Screen 水题
Problem G.Giant ScreenTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/con ...
- POJ 3077-Rounders(水题乱搞)
Rounders Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7697 Accepted: 4984 Descript ...
- Codeforces gym 100685 C. Cinderella 水题
C. CinderellaTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100685/problem/C ...
- Codeforces GYM 100114 B. Island 水题
B. Island Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100114 Description O ...
- Codeforces Round #367 (Div. 2)---水题 | dp | 01字典树
A.Beru-taxi 水题:有一个人站在(sx,sy)的位置,有n辆出租车,正向这个人匀速赶来,每个出租车的位置是(xi, yi) 速度是 Vi;求人最少需要等的时间: 单间循环即可: #inclu ...
- CodeForces 489B BerSU Ball (水题 双指针)
B. BerSU Ball time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- codeforces 577B B. Modulo Sum(水题)
题目链接: B. Modulo Sum time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- codeforces 696A Lorenzo Von Matterhorn 水题
这题一眼看就是水题,map随便计 然后我之所以发这个题解,是因为我用了log2()这个函数判断在哪一层 我只能说我真是太傻逼了,这个函数以前听人说有精度问题,还慢,为了图快用的,没想到被坑惨了,以后尽 ...
- CodeForces 589I Lottery (暴力,水题)
题意:给定 n 和 k,然后是 n 个数,表示1-k的一个值,问你修改最少的数,使得所有的1-k的数目都等于n/k. 析:水题,只要用每个数减去n/k,然后取模,加起来除以2,就ok了. 代码如下: ...
随机推荐
- Python9-进程理论-day35
#!/usr/bin/env python# -*- coding:utf-8 -*-# Author:Tim'''进程(Process)是计算机中的程序关于某数据集合上的一次运行活动,是系统进行资源 ...
- 欧拉函数:HDU1787-GCD Again(欧拉函数的模板)
GCD Again Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Sub ...
- ADB命令后台修改系统默认输入法
今天要研究uiautomator如何输入中文,看网上有一种常用的解决办法:http://www.cnblogs.com/yajing-zh/p/5125387.html在这篇博客最后提出来的问题,也是 ...
- HBase0.94.2-cdh4.2.0需求评估测试报告1.0之五
根据以上图分析得出以下结论: 1. 在上面的hbase配置下,顺序和随机写记录(每条记录1K),每写入86-87M(大小可配)左右数据生成一个磁盘文件(store file). 2. 在上面的hbas ...
- 《Nginx高性能Web服务器详解》
第1章 Nginx初探 第2章 Nginx服务器的安装部署 第3章 Nginx服务器架构初探 第4章 Nginx服务器的高级设置 第5章 Nginx服务器的Gzip压缩 第6章 Nginx服务器的Re ...
- bootstrap3兼容ie8浏览器
bootstrap3 兼容IE8浏览器 2016-01-22 14:01 442人阅读 评论(0) 收藏 举报 分类: html5(18) 目录(?)[+] 近期在使用bootstrap这 ...
- DB2 和 有道词典冲突: A communication error has been detected. Communication protocol being used: Reply.fill().
我在本机安装了DB2 9.5. 使用java jdbc连接,一直没有问题. QC for db2 连接 也一直没有问题. 突然有一天 Java程序连接 报错: A communication erro ...
- git status 下中文显示乱码问题解决
$ git status -s ?? "\350\257\264\346\230\216.txt\n $ printf & ...
- NOJ——1559Jump to the Top of Mountain(简单暴力DFS+渣渣代码)
[1559] Jump to the Top of Mountain 时间限制: 1000 ms 内存限制: 65535 K 问题描述 Have you played a game named Min ...
- win7中如何恢复UltraEdit的默认配置
自己win7上安装的UltraEdit 17.10.0.1015.由于编码格式不知道什么时候被改乱了,导致UE编写的java程序出现如下两种编译错误: D:\jcode>javac testco ...