原题链接: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. LeetCode(154) Find Minimum in Rotated Sorted Array II

    题目 Follow up for "Find Minimum in Rotated Sorted Array": What if duplicates are allowed? W ...

  2. Docker容器技术的核心原理

    目录 1 前言 2 docker容器技术 2.1 隔离:Namespace 2.2 限制:Cgroup 2.3 rootfs 2.4 镜像分层 3 docker容器与虚拟机的对比 1 前言 上图是百度 ...

  3. 水题:HDU1716-排列2

    排列2 Problem Description Ray又对数字的列产生了兴趣: 现有四张卡片,用这四张卡片能排列出很多不同的4位数,要求按从小到大的顺序输出这些4位数. Input 每组数据占一行,代 ...

  4. dwr介绍及配置

    DWR 编辑 DWR(Direct Web Remoting)是一个用于改善web页面与Java类交互的远程服务器端Ajax开源框架,可以帮助开发人员开发包含AJAX技术的网站.它可以允许在浏览器里的 ...

  5. 测试jsonp

    login<?php $type = $_GET['type']; if(empty($type)) { $url = ""; }else { if($type == 'lo ...

  6. iOS学习笔记46-Swift(六)扩展

    一.Swift扩展 扩展就是向一个已有的类.结构体或枚举类型添加新功能,这包括在没有权限获取原始源代码的情况下扩展类型的能力.扩展和 Objective-C中的分类(category)类似,但是它要比 ...

  7. 算法复习——区间dp

    感觉对区间dp也不好说些什么直接照搬讲义了2333 例题: 1.引水入城(洛谷1514) 这道题先开始看不出来到底和区间dp有什么卵关系···· 首先肯定是bfs暴力判一判可以覆盖到哪些城市····无 ...

  8. leetcode 26 水

    class Solution { public: int removeDuplicates(vector<int>& nums) { sort(nums.begin(),nums. ...

  9. 【spring aop切面】基础使用教程

    package tpf.aspect; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFact ...

  10. touch event 存疑

    1.原声js与借用jquery输出来的事件列表却不一样 function touchPlay(e) { e.preventDefault(); console.log(e); } var screen ...