记录编号 |
584936 |
评测结果 |
AAAAAAAAAA |
题目名称 |
送给圣诞夜的礼品 |
最终得分 |
100 |
用户昵称 |
┭┮﹏┭┮ |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.119 s |
提交时间 |
2023-11-17 07:42:37 |
内存使用 |
6.36 MiB |
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//矩阵快速幂
const int N = 15;
int n,m;
ll k;
struct Matrix{
int a[101][101],n,m;
void clear(){n = m = 0;memset(a,0,sizeof(a));}
Matrix operator * (const Matrix &x)const{
Matrix y;y.clear();
y.n = n;y.m = m;
for(int i = 1;i <= n;i++)
for(int j = 1;j <= m;j++)
for(int k = 1;k <= m;k++)
y.a[i][j] = y.a[i][j] + a[i][k] * x.a[k][j];
return y;
}
}c[N],f;
int main(){
freopen("christgift.in","r",stdin);
freopen("christgift.out","w",stdout);
scanf("%d%d%lld",&n,&m,&k);
f.n = 1,f.m = n;
for(int i = 1;i <= n;i++)f.a[1][i] = i;
for(int i = 1;i <= m;i++){
for(int j = 1;j <= n;j++){
int x;scanf("%d",&x);
c[i].a[x][j] = 1;
}
c[i].n = c[i].m = n;
if(i != 1)c[i] = c[i-1] * c[i];//矩阵乘法不满足交换律,这个位置不能换!!
}
ll op = k / m;
while(op){
if(op & 1)f = f * c[m];
c[m] = c[m] * c[m];
op >>= 1;
}
op = k % m;
if(op != 0)f = f * c[op];
for(int i = 1;i <= n;i++)printf("%d ",f.a[1][i]);
printf("\n");
return 0;
}