結果

問題 No.1569 Nixoracci's Number
ユーザー chocoruskchocorusk
提出日時 2021-08-15 01:51:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 484 ms / 2,000 ms
コード長 1,541 bytes
コンパイル時間 3,670 ms
コンパイル使用メモリ 188,928 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-16 00:13:05
合計ジャッジ時間 7,685 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 346 ms
6,940 KB
testcase_05 AC 20 ms
6,940 KB
testcase_06 AC 484 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 45 ms
6,940 KB
testcase_09 AC 4 ms
6,944 KB
testcase_10 AC 22 ms
6,944 KB
testcase_11 AC 73 ms
6,940 KB
testcase_12 AC 184 ms
6,944 KB
testcase_13 AC 238 ms
6,944 KB
testcase_14 AC 32 ms
6,940 KB
testcase_15 AC 335 ms
6,940 KB
testcase_16 AC 55 ms
6,940 KB
testcase_17 AC 26 ms
6,944 KB
testcase_18 AC 80 ms
6,944 KB
testcase_19 AC 21 ms
6,944 KB
testcase_20 AC 434 ms
6,940 KB
testcase_21 AC 204 ms
6,944 KB
testcase_22 AC 48 ms
6,944 KB
testcase_23 AC 426 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
vector<vector<int>> matrixmul(int l, int m, int n, vector<vector<int>> a, vector<vector<int>> b){
	vector<vector<int>> c(l, vector<int>(n));
	for(int i=0; i<l; i++){
		for(int k=0; k<m; k++){
			for(int j=0; j<n; j++){
				c[i][j]^=(a[i][k]&b[k][j]);
			}
		}
	}
	return c;
}
vector<vector<int>> matrixpow(int n, vector<vector<int>> a, ll k){
	vector<vector<int>> ap=a, ans(n, vector<int>(n));
	for(int i=0; i<n; i++) ans[i][i]=1;
	while(k){
		if(k&1) ans=matrixmul(n, n, n, ap, ans);
		ap=matrixmul(n, n, n, ap, ap);
		k>>=1;
	}
	return ans;
}
int main()
{
    int n; ll k;
    cin>>n>>k;
    ll a[202];
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    vector<vector<int>> mat(n, vector<int>(n));
    for(int i=0; i<n-1; i++) mat[i][i+1]=1;
    for(int i=0; i<n; i++) mat[n-1][i]=1;
    mat=matrixpow(n, mat, k-1);
    ll ans=0;
    for(int i=0; i<n; i++){
        if(mat[0][i]) ans^=a[i];
    }
    cout<<ans<<endl;
    return 0;
}
0