-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDSA02008 - CHỌN SỐ TỪ MA TRẬN VUÔNG CẤP N
65 lines (65 loc) · 1.18 KB
/
DSA02008 - CHỌN SỐ TỪ MA TRẬN VUÔNG CẤP N
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
#include<bits/stdc++.h>
#include<string>
#include<vector>
#define endl '\n'
#define alphaa "abcdefghijklmnopqrstuvwxyz"
#define ALPHAA "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define f(i,a,b) for(int i=a;i<=b;i++)
#define f1(i,n) for(int i=1;i<=n;i++)
#define f0(i,n) for(int i=0;i<n;i++)
#define sp(x) cout<<x<<" ";
#define en(x) cout<<x<<endl;
using namespace std;
typedef long long ll;
const int N=1e6+3;
const int MOD=1e9+7;
int a[100][100];
int res,k,n;
int x[100];
bool check[100];
vector<int>Res;
void sinh(int i)
{
f1(j,n)
{
if(!check[j])
{
x[i]=j;
check[j]=true;
if(i==n)
{
res=0;
f1(l,n) res+=a[l][x[l]];
if(res==k)
{
f1(l,n) Res.push_back(x[l]);
}
}
else sinh(i+1);
check[j]=false;
}
}
}
void xuly()
{
cin>>n>>k;
f1(i,n)
f1(j,n)
cin>>a[i][j];
sinh(1);
cout<<Res.size()/n;
for(int i=0;i<Res.size();i++)
{
if(i%n==0) cout<<endl;
cout<<Res[i]<<" ";
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int t=1;
//cin>>t;
while(t--) xuly();
return 0;
}