原题链接: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 水题乱搞的更多相关文章

  1. Codeforces Gym 100286G Giant Screen 水题

    Problem G.Giant ScreenTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/con ...

  2. POJ 3077-Rounders(水题乱搞)

    Rounders Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7697   Accepted: 4984 Descript ...

  3. Codeforces gym 100685 C. Cinderella 水题

    C. CinderellaTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100685/problem/C ...

  4. Codeforces GYM 100114 B. Island 水题

    B. Island Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100114 Description O ...

  5. Codeforces Round #367 (Div. 2)---水题 | dp | 01字典树

    A.Beru-taxi 水题:有一个人站在(sx,sy)的位置,有n辆出租车,正向这个人匀速赶来,每个出租车的位置是(xi, yi) 速度是 Vi;求人最少需要等的时间: 单间循环即可: #inclu ...

  6. CodeForces 489B BerSU Ball (水题 双指针)

    B. BerSU Ball time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  7. codeforces 577B B. Modulo Sum(水题)

    题目链接: B. Modulo Sum time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  8. codeforces 696A Lorenzo Von Matterhorn 水题

    这题一眼看就是水题,map随便计 然后我之所以发这个题解,是因为我用了log2()这个函数判断在哪一层 我只能说我真是太傻逼了,这个函数以前听人说有精度问题,还慢,为了图快用的,没想到被坑惨了,以后尽 ...

  9. CodeForces 589I Lottery (暴力,水题)

    题意:给定 n 和 k,然后是 n 个数,表示1-k的一个值,问你修改最少的数,使得所有的1-k的数目都等于n/k. 析:水题,只要用每个数减去n/k,然后取模,加起来除以2,就ok了. 代码如下: ...

随机推荐

  1. MAC系统里安装 Python

    首先MAC系统自带Python2.6/2.7.这是因为有些系统文件需要.但是对于我来说,我需要用到Python3,所以需要自己下载安装.这时候,就有一个非常强大的软件 Homebrew.(安装方法见官 ...

  2. Applied Nonparametric Statistics-lec3

    Ref: https://onlinecourses.science.psu.edu/stat464/print/book/export/html/4 使用非参数方法的优势: 1. 对总体分布做的假设 ...

  3. POJ:3041-Asteroids(匈牙利算法模板)

    传送门:http://poj.org/problem?id=3041 Asteroids Time Limit: 1000MS Memory Limit: 65536K Description Bes ...

  4. German Collegiate Programming Contest 2015

    // Legacy Code #include <iostream> #include <cstdio> #include <cstring> #include & ...

  5. VS2017生成.net core项目报错:The current .NET SDK does not support targeting .NET Core 2.1. Either

    今天在生成一个项目的时候,生成报错,错误如下:The current .NET SDK does not support targeting .NET Core 2.1.  Either target ...

  6. 全网最详细python中socket套接字send与sendall的区别

    将数据发送到套接字. 套接字必须连接到远程套接字.  返回发送的字节数. 应用程序负责检查是否已发送所有数据; 如果仅传输了一些数据, 则应用程序需要尝试传递剩余数据.(需要用户自己完成) 将数据发送 ...

  7. Linux性能查看

    1.TOP top  登录后默认按进程的CPU使用情况排序,  按M则按内存使用排序 2. vmstat 2 2 显示系统负载 3. free  -m 查看内存使用情况 4.抓包 tcpdump -i ...

  8. python-网络编程-03

    首先我们可以看下可以最简单的交互性的服务端和客户端程序 server import socket def main(): sock = socket.socket(socket.AF_INET,soc ...

  9. TensorFlow笔记——

    主要依赖包 protocal buffer 处理结构化数据的工具:序列化(结构化数据->数据流) + 还原(数据流->结构化数据) protocol buffer与XML和JSON的区别: ...

  10. IDE介绍以及Eclipse的简单使用

    一.IDE介绍 ①   什么是IDE? 1.  IDE全称是”Integrated Development Environment”,中文称为“集成开发环境”; 2.是用于提供程序开发环境的应用程序, ...