結果
問題 | No.1136 Four Points Tour |
ユーザー | Tlapesium |
提出日時 | 2021-01-24 03:05:16 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 2,936 bytes |
コンパイル時間 | 3,325 ms |
コンパイル使用メモリ | 233,908 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-10 14:43:07 |
合計ジャッジ時間 | 4,810 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,812 KB |
testcase_01 | AC | 1 ms
6,944 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | AC | 1 ms
6,944 KB |
testcase_04 | AC | 1 ms
6,940 KB |
testcase_05 | AC | 2 ms
6,944 KB |
testcase_06 | AC | 1 ms
6,944 KB |
testcase_07 | AC | 1 ms
6,940 KB |
testcase_08 | AC | 2 ms
6,940 KB |
testcase_09 | AC | 2 ms
6,944 KB |
testcase_10 | AC | 2 ms
6,940 KB |
testcase_11 | AC | 2 ms
6,940 KB |
testcase_12 | AC | 1 ms
6,944 KB |
testcase_13 | AC | 1 ms
6,940 KB |
testcase_14 | AC | 1 ms
6,944 KB |
testcase_15 | AC | 2 ms
6,940 KB |
testcase_16 | AC | 1 ms
6,944 KB |
testcase_17 | AC | 2 ms
6,940 KB |
testcase_18 | AC | 1 ms
6,944 KB |
testcase_19 | AC | 1 ms
6,940 KB |
testcase_20 | AC | 1 ms
6,944 KB |
testcase_21 | AC | 2 ms
6,944 KB |
01_Sample03_evil.txt | AC | 2 ms
6,940 KB |
04_Rnd_large_evil1.txt | AC | 2 ms
6,940 KB |
04_Rnd_large_evil2.txt | AC | 1 ms
6,940 KB |
04_Rnd_large_evil3.txt | AC | 2 ms
6,944 KB |
04_Rnd_large_evil4.txt | AC | 1 ms
6,944 KB |
04_Rnd_large_evil5.txt | AC | 1 ms
6,944 KB |
04_Rnd_large_evil6.txt | AC | 2 ms
6,940 KB |
04_Rnd_large_evil7.txt | AC | 2 ms
6,940 KB |
04_Rnd_large_evil8.txt | AC | 2 ms
6,940 KB |
04_Rnd_large_evil9.txt | AC | 2 ms
6,944 KB |
04_Rnd_large_evil10.txt | AC | 1 ms
6,940 KB |
05_Rnd_huge_evil1.txt | AC | 2 ms
6,944 KB |
05_Rnd_huge_evil2.txt | AC | 1 ms
6,940 KB |
05_Rnd_huge_evil3.txt | AC | 1 ms
6,944 KB |
05_Rnd_huge_evil4.txt | AC | 1 ms
6,944 KB |
05_Rnd_huge_evil5.txt | AC | 2 ms
6,944 KB |
05_Rnd_huge_evil6.txt | AC | 2 ms
6,940 KB |
05_Rnd_huge_evil7.txt | AC | 1 ms
6,944 KB |
99_evil_01.txt | AC | 2 ms
6,940 KB |
ソースコード
#pragma GCC optimize("O3") #pragma GCC optimize ("unroll-loops") #pragma GCC target ("avx2") #define io_init cin.tie(0);ios::sync_with_stdio(0);cout<<fixed<<setprecision(20) #include <bits/stdc++.h> constexpr int INF = 2147483647; constexpr long long int INF_LL = 9223372036854775807; constexpr int MOD = 1000000007; constexpr double PI = 3.14159265358979323846; using namespace std; typedef long long int ll; typedef unsigned long long int ull; struct matrix { public: std::vector<std::vector<long long>> v; matrix() = default; matrix(int N) { v = std::vector(N, std::vector(N, 0LL)); for (int i = 0; i < N; i++)v[i][i] = 1; } matrix(int N, int M, ll x) { v = std::vector(N, std::vector(M, x)); } matrix(std::initializer_list<std::initializer_list<long long>> list) { for (auto&& row : list) { v.push_back(row); } } int height() const { return v.size(); }; int width() const { return v[0].size(); }; matrix& operator=(std::initializer_list<std::initializer_list<long long>> list) { v.clear(); for (auto&& row : list) { v.push_back(row); } return *this; } matrix& operator+= (const matrix& r) { for (int i = 0; i < height(); i++)for (int j = 0; j < width(); j++) { v[i][j] += r.v[i][j]; } return *this; } matrix& operator-= (const matrix& r) { for (int i = 0; i < height(); i++)for (int j = 0; j < width(); j++) { v[i][j] -= r.v[i][j]; } return *this; } matrix& operator*= (const matrix& r) { std::vector c(height(), std::vector(r.width(), 0LL)); for (int i = 0; i < height(); i++) { for (int j = 0; j < r.width(); j++) { for (int k = 0; k < width(); k++) { c[i][j] += v[i][k] * r.v[k][j]; } } } v = c; return *this; } void dump() { for (int i = 0; i < height(); i++)for (int j = 0; j < width(); j++) { std::cout << v[i][j] << (j == width() - 1 ? "\n" : " "); } } }; matrix operator+(const matrix& l, const matrix& r) { return matrix(l) += r; } matrix operator-(const matrix& l, const matrix& r) { return matrix(l) -= r; } matrix operator*(const matrix& l, const matrix& r) { return matrix(l) *= r; } struct modmat : public matrix { using matrix::matrix; modmat& operator*= (const modmat& r) { std::vector c(height(), std::vector(r.width(), 0LL)); for (int i = 0; i < height(); i++) { for (int j = 0; j < r.width(); j++) { for (int k = 0; k < width(); k++) { c[i][j] += v[i][k] * r.v[k][j] % MOD; c[i][j] %= MOD; } } } v = c; return *this; } }; modmat operator*(const modmat& l, const modmat& r) { return modmat(l) *= r; } modmat matpow(const modmat& x, ll n) { if (n == 0)return modmat(x.height()); if (n % 2 == 0) { modmat tmp = matpow(x, n / 2); return tmp * tmp; } else { return x * matpow(x, n - 1); } } int main() { ll N; cin >> N; auto m = matpow(modmat{ {0,1,1,1},{1,0,1,1},{1,1,0,1},{1,1,1,0} }, N); m = m * modmat{ {1},{0},{0},{0} }; cout << m.v[0][0] << endl; }