原题链接: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(128) Longest Consecutive Sequence

    题目 Given an unsorted array of integers, find the length of the longest consecutive elements sequence ...

  2. 【HIHOCODER 1176】 欧拉路·一

    描述 小Hi和小Ho最近在玩一个解密类的游戏,他们需要控制角色在一片原始丛林里面探险,收集道具,并找到最后的宝藏.现在他们控制的角色来到了一个很大的湖边.湖上有N个小岛(编号1..N),以及连接小岛的 ...

  3. POJ:2632-Crashing Robots

    Crashing Robots Time Limit: 1000MS Memory Limit: 65536K Description In a modernized warehouse, robot ...

  4. [solution]腾讯TEG_计算广告组_算法题

    度娘笔试归来,题目实打实的,感觉真心不易,上百号人就抢那么几个坑......只恨自己平时积累太少啊~ 故曝一道鹅厂面试用的算法题(当时我就死在了这题上),来为度娘家攒一下RP~ 题目: 对于长度为N的 ...

  5. 开源OA系统启动:基础数据,工作流设计

    原文:http://www.cnblogs.com/kwklover/archive/2007/01/13/bpoweroa_03_baseandworkflowdesign.html自从开源OA系统 ...

  6. LINQ to SQL和Entity Framework对比与关联

    LINQ to SQL和Entity Framework都是一种包含LINQ功能的对象关系映射技术.他们之间的本质区别在于EF对数据库架构和我们查询的类型实行了更好的解耦.使用EF,我们查询的对象不再 ...

  7. oracle结构-内存结构与动态内存管理

    内存结构与动态内存管理 内存是影响数据库性能的重要因素. oracle8i使用静态内存管理,即,SGA内是预先在参数中配置好的,数据库启动时就按这些配置来进行内在分配,oracle10g引入了动态内存 ...

  8. quarz spring boot

    package com.pkfare.task.manage.config; import org.quartz.spi.TriggerFiredBundle; import org.springfr ...

  9. 记一次WMS的系统改造(1)-分析问题

    海外落地中的困境 目前面临主要的问题是"人",仓储系统主要辅助仓储人员进行生产,所以人变了其实一切就都已经变了,系统在海外面临最大的问题就是人变了. 这套软件是在国内的运营体系 ...

  10. python + selenium - selenium常用元素定位

    1. Chrome定位工具 打开Chrome浏览器,按F12会弹出开发者工具选项,选择Elements: 1)鼠标点击最左边箭头 2)鼠标滑动到页面中你要操作的元素,单击一下 3)对应的html元素内 ...