第二十一次codeforces竞技结束 #277 Div 2
来源:互联网 发布:乐清知临寄宿学校 编辑:程序博客网 时间:2024/05/14 03:03
寝室外面有个男生在和女生打分手电话……时长85分钟,我只能含泪努力,结果还是坑掉了这场……55555‘
Problems
Calculating Function
standard input/output
1 s, 256 MBOR in Matrix
standard input/output
1 s, 256 MBPalindrome Transformation
standard input/output
1 s, 256 MBValid Sets
standard input/output
1 s, 256 MBLIS of Sequence
standard input/output
2 s, 256 MB大家都表示简单的一场,我一直被打断一直低级错误,WA数空前新高……哭
#include <cmath> #include <cctype>#include <cstdio>#include <string>#include <cstdlib>#include <cstring>#include <iostream>#include <algorithm>using namespace std;#define Max(a,b) ((a)>(b)?(a):(b))#define Min(a,b) ((a)<(b)?(a):(b))bool cmp(const int a, const int b){return a > b;}int main(){long long n=0;cin>>n;if(n%2==0)cout<<n/2;else cout<<n/2-n;return 0;}
有一个矩阵A,是由01组成的,然后逐行逐列进行OR逻辑运算,得到的结果为B矩阵。
简单来说,就是如果A里有个1,那么B里这个1的所在行和所在列都成1了。
给结果矩阵问原矩阵是什么。
先逐行读,找出全为1的行,记录位置,然后逐列读,找出全为1的列,同时判断不为全1行却出现1的话直接判NO。
获得行列位置之后一一对应,行、列用剩下的都和对方的第一个下标挤一挤就好。
Code:
#include <cmath> #include <cctype>#include <cstdio>#include <string>#include <cstdlib>#include <cstring>#include <iostream>#include <algorithm>using namespace std;int mat[111][111]={0};int ans[111][111]={0};int visrow[111]={0};int col[111]={0},vcol=0;int row[111]={0},vrow=0;#define Max(a,b) ((a)>(b)?(a):(b))#define Min(a,b) ((a)<(b)?(a):(b))bool cmp(const int a, const int b){return a > b;}int main(){int n,m;cin>>n>>m;int flag=0,zero=0;for(int i=0;i<n;i++){scanf("%d",&mat[i][0]);flag=0;if(mat[i][0]) flag=1,zero=1;for(int j=1;j<m;j++){scanf("%d",&mat[i][j]);if(mat[i][j]) zero=1;if(mat[i][j]!=mat[i][0]){flag=0;}}if(flag) row[vrow++]=i, visrow[i]=1;}for(int j=0;j<m;j++){flag=0;if(mat[0][j]) flag=1;for(int i=1;i<n;i++){if(mat[i][j]!=mat[0][j]){flag=0;}}if(flag) col[vcol++]=j;else{for(int i=0;i<n;i++){if(mat[i][j] && visrow[i]==0){cout<<"NO";return 0;}}}}if(zero==0){cout<<"YES"<<endl;for(int i=0;i<n;i++){printf("%d",mat[i][0]);for(int j=1;j<m;j++){printf(" %d",mat[i][j]);}printf("\n");}return 0;}if(vcol==0 || vrow==0){cout<<"NO";return 0;}int l=max(vcol,vrow),s=min(vcol,vrow),cntp=0;for(cntp=0;cntp<s;cntp++){ans[row[cntp]][col[cntp]]=1;}if(l==vrow)for(;cntp<l;cntp++){ans[row[cntp]][col[0]]=1;}else for(;cntp<l;cntp++){ans[row[0]][col[cntp]]=1;}printf("YES\n");for(int i=0;i<n;i++){printf("%d",ans[i][0]);for(int j=1;j<m;j++){printf(" %d",ans[i][j]);}printf("\n");}return 0;}
0 0
- 第二十一次codeforces竞技结束 #277 Div 2
- 第二十次codeforces竞技结束 #276 Div 2
- 第二十二次codeforces竞技结束 #278 Div 2
- 第二十三次codeforces竞技结束 #279 Div 2
- 第二十四次codeforces竞技结束 #281 Div 2
- 第二十五次codeforces竞技结束 #285 Div 2
- 第十一次codeforces竞技结束 #262 Div 2
- 第三十一次codeforces竞技结束 #297 Div 2
- 第一次codeforces竞技结束 #238 Div 2
- 第二次codeforces竞技结束 #249 Div 2
- 第三次codeforces竞技结束 #254 Div 2
- 第四次codeforces竞技结束 #FF(#255) Div 2
- 第五次codeforces竞技结束 #256 Div 2
- 第六次codeforces竞技结束 #257 Div 2
- 第七次codeforces竞技结束 #258 Div 2
- 第八次codeforces竞技结束 #259 Div 2
- 第九次codeforces竞技结束 #260 Div 2
- 第十次codeforces竞技结束 #261 Div 2
- Firefox下的window.event问题
- int,NSInteger,NSUInteger,NSNumber区别
- 怀恋抗日的英雄
- JavaScript冒泡实例
- 黑马程序员-c语言结构体,联合以及枚举
- 第二十一次codeforces竞技结束 #277 Div 2
- 黑马程序员-c语言宏定义以及外部变量
- Spark - A tiny Sinatra inspired framework for creating web applications in Java 8 with minimal effor
- Spark Getting started
- 第二十二次codeforces竞技结束 #278 Div 2
- The substring() Method in JDK 6 and JDK 7
- Script Control 组件Win7 X64平台运行问题及示例
- jQuery中$.get $.post $.getJSON $.ajax方法详解
- jQuery中$.get、$.post、$.getJSON和$.ajax的用法