-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path10895.cpp
72 lines (70 loc) · 1.29 KB
/
10895.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <iostream>
#include <vector>
#include <queue>
#define foi( i , n , k) for( int i = n ; i < k ; ++i )
using namespace std;
int main()
{
int x,y;
while( scanf("%d%d",&x,&y) != EOF )
{
vector< vector <int> > mat(x,vector<int>(y,0));
int r,c;
foi( i , 0 , x)
{
scanf("%d",&r);
queue<int> pos,dat;
foi( j , 0 , r)
{
scanf("%d",&c);
pos.push(c-1);
}
foi( j , 0 , r)
{
scanf("%d",&c);
dat.push(c);
}
while(!pos.empty())
{
int p,d;
p=pos.front();
d=dat.front();
pos.pop();
dat.pop();
mat[i][p]=d;
}
}
printf("%d %d\n",y,x );
foi( i , 0 , y)
{
queue<int> pos,dat;
foi( j , 0 , x)
{
if( mat[j][i] )
{
pos.push(j);
dat.push(mat[j][i]);
}
}
printf("%d",(int)pos.size());
if(pos.empty())
printf("\n\n");
else
{
while(!pos.empty()){
printf(" %d",pos.front()+1);
pos.pop();
}
printf("\n");
while(!dat.empty()){
printf("%d",dat.front());
dat.pop();
if(!dat.empty())
printf(" " );
}
printf("\n");
}
}
}
return 0;
}