原题链接: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. 什么是python中的元类

    所属网站分类: python高级 > 面向对象 作者:goodbody 原文链接: http://www.pythonheidong.com/blog/article/11/ 来源:python ...

  2. python 中 * 与**的使用

    1.参数中使用如果是函数定义中参数前的*表示的是将调用时的多个参数放入元组中,**则表示将调用函数时的关键字参数放入一个字典中 如定义以下函数 def func(*args): print(args) ...

  3. SQL防止重复提交和Filter

    /class User package com.neuedu.bean; import java.io.Serializable; public class User implements Seria ...

  4. LeetCode(205)Isomorphic Strings

    题目 Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if the ch ...

  5. LeetCode(238) Product of Array Except Self

    题目 Given an array of n integers where n > 1, nums, return an array output such that output[i] is ...

  6. 【HIHOCODER 1181】欧拉路·二

    描述 在上一回中小Hi和小Ho控制着主角收集了分散在各个木桥上的道具,这些道具其实是一块一块骨牌. 主角继续往前走,面前出现了一座石桥,石桥的尽头有一道火焰墙,似乎无法通过. 小Hi注意到在桥头有一张 ...

  7. Nordic Collegiate Programming Contest 2015​ B. Bell Ringing

    Method ringing is used to ring bells in churches, particularly in England. Suppose there are 6 bells ...

  8. Post页面爬取失败__编码问题

    python3爬取Post页面时, 报以下错误 "POST data should be bytes or an iterable of bytes. It cannot be of typ ...

  9. [转载] C语言细节,写的非常棒!

    这篇文章主要讨论C语言细节问题.在找一份工作的时候,语言细节占的比例非常小,之前看某个贴着讨论,估计语言细节在面试中,占了10%的比重都不到,那为什么还要研究C语言的细节呢,我觉得有三个原因促使我总结 ...

  10. 【NOIP2017】逛公园 拆点最短路+拓扑(记忆化搜索

    题目描述 策策同学特别喜欢逛公园.公园可以看成一张N个点M条边构成的有向图,且没有 自环和重边.其中1号点是公园的入口,N号点是公园的出口,每条边有一个非负权值, 代表策策经过这条边所要花的时间. 策 ...