UVa 10895 Matrix Transpose
来源:互联网 发布:淘宝刷心悦会封号吗 编辑:程序博客网 时间:2024/05/22 17:22
#include <iostream>#include <cstdio>#include <cstring>#include <vector>using namespace std;int a[10010];int b[10010][10010];int main(){ // freopen("in.txt","r",stdin); int m,n; int num; while(~scanf("%d%d",&m,&n)){ vector<int>cnt[n]; vector<int>ans[n]; int maxn = max(m,n); memset(b,0,sizeof(b)); for(int i=0;i<m;++i){ scanf("%d",&num); if(num==0)continue; for(int j=0;j<num;++j)scanf("%d",&a[j]); for(int j=0;j<num;++j)scanf("%d",&b[i][a[j]-1]); //注意矩阵的下标 } for(int j=0;j<n;++j){ cnt[j].clear(); ans[j].clear(); for(int i=0;i<m;++i){ if(b[i][j]!=0){ cnt[j].push_back(i+1); int crt = b[i][j]; ans[j].push_back(crt); } } } printf("%d %d\n",n,m); for(int i=0;i<n;++i){ int len = ans[i].size(); if(cnt[i].size()==0){printf("0\n\n");continue;} printf("%d",cnt[i].size()); for(int j=0;j<len;++j){ j== len-1 ? printf(" %d\n",cnt[i][j]) : printf(" %d",cnt[i][j]); } for(int j=0;j<len;++j){ j== len-1 ? printf("%d\n",ans[i][j]) : printf("%d ",ans[i][j]); } } } return 0;}
0 0
- Uva 10895 - Matrix Transpose
- uva 10895 Matrix Transpose
- UVA 10895 Matrix Transpose
- UVA - 10895 Matrix Transpose
- UVa 10895 Matrix Transpose
- UVa 10895 - Matrix Transpose
- UVA 10895 - Matrix Transpose(STL)
- uva 10895 - Matrix Transpose(STL)
- UVA - 10895Matrix Transpose(vector)
- UVA 10895——Matrix Transpose
- Matrix Transpose
- Inverse transpose matrix
- Sparse Matrix's Transpose
- numpy基础——matrix.transpose() 和 matrix.getA()
- Programming trivia: 4x4 integer matrix transpose in SSE2
- UVA 11019 Matrix Matcher
- Uva 11019 Matrix Matcher
- UVA 11019 Matrix Matcher
- 解决: failed to lazily initialize a collection of role: no session or session was closed问题
- 自然语言处理中的一些问题
- 关于struts2的配置
- 浅谈土地利用图件缩编方法的应用研究
- UVa 536 Tree Recovery
- UVa 10895 Matrix Transpose
- 使用HAProxy、PHP、Redis和MySQL支撑10亿请求每周架构细节
- UVa 548 Tree
- UVa 11995 I Can Guess the Data Structure!
- Android笔记之——framework框架
- 求两个日期之间间隔的天数,Python实现
- Android笔记之——APK的运行状态
- Android笔记——-Binder类框架
- PAT 1044. Shopping in Mars