結果

問題 No.572 妖精の演奏
ユーザー sugarrrsugarrr
提出日時 2018-07-22 11:23:42
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,574 bytes
コンパイル時間 559 ms
コンパイル使用メモリ 76,132 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-27 00:50:12
合計ジャッジ時間 1,880 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=1000000000000;/*10^12*/
#define rep(i,l,r) for(ll i=l;i<=r;i++)
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}


//////////////////////////////////////

int main(){
    int n,m;cin>>n>>m;
    int a[m][m];rep(i,0,m-1)rep(j,0,m-1)cin>>a[i][j];
    ll dp[m][m][35];memset(dp,0,sizeof(dp));
    rep(i,0,m-1)rep(j,0,m-1){
        dp[i][j][0]=a[i][j];
    }
    rep(k,1,34){
        rep(s,0,m-1){
            rep(t,0,m-1){
                rep(i,0,m-1){
                    dp[s][t][k]=max(dp[s][t][k],dp[s][i][k-1]+dp[i][t][k-1]);
                }
            }
        }
    }
    
  /*  rep(s,0,m-1){
        rep(t,0,m-1){
            cout<<dp[s][t][2]<<" ";
        }
        cout<<endl;
    }*/
    
    ll x[35];memset(x,0,sizeof(x));
    rep(i,0,34){
        rep(s,0,m-1){
            rep(t,0,m-1){
                x[i]=max(x[i],dp[s][t][i]);
            }
        }
    }
  /*  rep(i,0,3){
        cout<<x[i]<<" ";
    }*/
    
    ll ans=0;
    int stop=(int)log2(n);
    rep(i,0,stop+1){
        if(((n>>i)&1)==1)ans+=x[i];
    }
    cout<<ans<<endl;
    return 0;
}
0