GCJ Crazy Rows 水题-贪心
来源:互联网 发布:mac删除软件不用密码 编辑:程序博客网 时间:2024/05/14 16:08
#include <cstdio>#include <iostream>#include <algorithm>#include <queue>#include <stack>#include <climits>#include <cstring>#include <cmath>#include <map>#include <set>using namespace std;int main(){int n;char a[45][45];while(scanf("%d",&n)!=EOF){getchar();for(int i = 0;i < n;i++){for(int j = 0;j < n;j++){a[i][j] = getchar();}getchar();}int num[45];for(int i = 0;i < n;i++){num[i] = -1;for(int j = 0;j < n;j++){if(a[i][j] == '1')num[i] = j;}}int ans = 0;for(int i = 0;i < n;i++){if(num[i] > i){int j;for(j = i+1; j < n;j++){if(num[j] <= i){break;}}for(int k = j;k > i;k--){swap(num[k],num[k-1]);ans ++;}}}cout << ans << endl;}return 0;}
0 0
- GCJ Crazy Rows 水题-贪心
- GCJ Crazy Rows
- Crazy Rows————GCJ 2009 Round2A(简单贪心)
- GCJ 2009 Round2 A (Crazy Rows)
- GCJ--Crazy Rows (2009 Round2 A)
- GCJ 2009 Round2 Problem A. Crazy Rows
- GCJ 2009 Round2 A Crazy Rows
- GCJ 2009 Round 2 Problem A. Crazy Rows
- GCJ Round 2 2009 Problem A. Crazy Rows
- 每天水一水 Crazy Rows (2009 Round2 A) GCJ
- Crazy Rows
- GCJ 2009 Problem A. Crazy Rows【位运算要加LL】
- 挑战2.7.2 Round 2 2009 A. Crazy Rows 贪心
- [Code Jam] Crazy Rows
- Code Jam 2009 Round2 Problem A. Crazy Rows —— 贪心
- crazy Rows 2009 Round2 A
- 挑战GCJ的题目: crazy row
- Crazy Rows (GoogleCode Jam 2009 Round2 A)
- rabbitMQ
- ViewPager onPageChangeListener总结
- Qt 读写文件,并显示到tablewidget
- scanf函数用法详解
- Autolayout 使用 总结点
- GCJ Crazy Rows 水题-贪心
- 安卓巴士
- 深入理解html5系列-文本标签
- Android开发中很少人才知道的一些解决小错误的方法(一直更新中)
- Android.mk 文件语法规范
- hdu4511---小明系列故事——女友的考验(AC自动机+dp)
- 记录一个自动算高的问题
- Linux上搭建软件iSCSI存储设备
- Android SDK manager更新时候失败