/ tabris /

记录详情

Time Exceeded

/in/foo.cc: In member function 'void Matrix::display()':
/in/foo.cc:26:37: warning: format '%d' expects argument of type 'int', but argument 2 has type 'LL {aka long long int}' [-Wformat=]
                 printf("%d ",m[i][j]);
                                     ^
# 状态 耗时 内存占用
#1 Time Exceeded ≥10003ms ≥2.246 MiB
#2 Time Exceeded ≥10005ms ≥2.25 MiB
#3 Accepted 98ms 1.988 MiB
#4 Accepted 115ms 1.973 MiB
#5 Accepted 127ms 1.977 MiB

代码

#pragma GCC optimize (2)
#include <bits/stdc++.h>
typedef long long int LL;
using namespace std;

const int M = 200+5;
const int MOD = 1e9+7;
/****************************************************/
int n,m,k;

struct Matrix{
    LL m[M][M];
    void clearO(){
        for(int i=0; i<n; i++) //初始化矩阵
            for(int j=0; j<n; j++)
                m[i][j] = 0;
    }
    void clearE(){
        for(int i=0; i<n; i++) //初始化矩阵
            for(int j=0; j<n; j++)
                m[i][j] = (i==j);
    }
    void display(){
        for(int i=0; i<n; i++){
            for(int j=0; j<n; j++)
                printf("%d ",m[i][j]);
            puts("");
        }
        puts("  -------  ");
    }
};

Matrix a,b,c,d;

Matrix operator * (Matrix &a,Matrix &b){
    c.clearO();
    for(int k=0;k<n;k++)for(int i=0;i<n;i++)for(int j=0;j<n;j++)
        c.m[i][j]=(c.m[i][j]+a.m[i][k]*b.m[k][j]+MOD)%MOD;
    return c;
}

// Matrix operator * (Matrix &a,Matrix &b){
//     c.clearO();
//     for (int k = 0; k < n; k++){
//         for (int j = 0; j < n; j++){
//             c.m[0][j] = (c.m[0][j] + a.m[0][k] * b.m[k][j]) % MOD;
//         }    
//     }
//     for (int i = 1; i < n; i++){
//         c.m[i][0] = c.m[i - 1][n - 1];
//         for (int j = 1; j < n; j++)
//             c.m[i][j] = c.m[i - 1][j - 1];
//     }
//     return c;
// }

Matrix operator ^ (Matrix &a,LL b){
    d.clearE();
    for(;b;b>>=1,a=a*a)
        if(b&1) d=d*a;
    return d;
}

int main(){
    // freopen("tiS2_1.in" ,"r",stdin);
    // freopen("tiS2_1.out","w",stdout);

    int _ = 1;
    for(scanf("%d",&_);_--;){
        scanf("%d%d%d",&n,&m,&k);
        
        a.clearO(),b.clearO();
        for(int i=0;i<n;i++) scanf("%lld",&a.m[0][i]);
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if(i!=j&&min(abs((j-i+n)%n),abs((i-j+n)%n))<k) {
                    b.m[i][j] = k-min(abs((j-i+n)%n),abs((i-j+n)%n));
                }
            }
        }
        b = b^(m);
        a = a*b;
        printf("%lld",a.m[0][0]);
        for(int i=1;i<n;i++) printf(" %lld",a.m[0][i]);
        puts("");
    }
    return 0;
}

信息

递交者
类型
递交
题目
tabris is SirBat 2
语言
C++
递交时间
2017-11-19 18:50:15
评测时间
2017-11-19 18:50:15
评测机
分数
384
总耗时
≥20350ms
峰值内存
≥2.25 MiB