0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-09-19 16:45:25 +00:00

#1738. 【2022.11.7 NOIP 模拟赛】序列(sequence)

https://sjzezoj.com/submission/63900
This commit is contained in:
Baoshuo Ren 2022-11-07 22:04:27 +08:00
parent 01e14ba3fc
commit 0a6f04d059
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
66 changed files with 303 additions and 0 deletions

108
S2OJ/1738/1738.cpp Normal file
View File

@ -0,0 +1,108 @@
#include <iostream>
#include <algorithm>
#include <cstring>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 1e6 + 5,
K = 105;
const int mod = 1e9 + 7;
int n, k, a[N];
long long m, f[N], s, ans;
std::pair<long long, int> sum[N];
class Matrix {
private:
long long data[K][K];
public:
Matrix() {
memset(data, 0x00, sizeof(data));
};
void build() {
for (int i = 1; i <= k; i++) data[i][i] = 1;
}
long long *operator[](int x) {
return data[x];
}
Matrix operator*(Matrix b) {
Matrix res;
for (int i = 1; i <= k; i++) {
for (int j = 1; j <= k; j++) {
for (int l = 1; l <= k; l++) {
res[i][j] = (res[i][j] + data[i][l] * b[l][j]) % mod;
}
}
}
return res;
}
} z, res;
Matrix binpow(Matrix a, long long b) {
Matrix res;
res.build();
while (b) {
if (b & 1) res = res * a;
a = a * a;
b >>= 1;
}
return res;
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> m >> k;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = 1; i <= n; i++) {
f[i] = (s + 1) % mod;
s = ((s - sum[a[i]].first) % mod + mod) % mod;
sum[a[i]].first = f[i];
s = (s + sum[a[i]].first) % mod;
sum[a[i]].second = i;
}
std::sort(sum + 1, sum + 1 + k, [&](auto a, auto b) -> bool { return a.second < b.second; });
for (int i = 1; i <= k; i++) {
res[1][i] = sum[i].first;
}
res[1][k + 1] = s;
res[1][k + 2] = 1;
for (int i = 1; i < k; i++) {
z[i + 1][i] = 1;
}
z[1][k + 1] = mod - 1;
z[k + 1][k] = 1;
z[k + 1][k + 1] = 2;
z[k + 2][k] = 1;
z[k + 2][k + 1] = 1;
z[k + 2][k + 2] = 1;
k += 2;
res = res * binpow(z, m);
cout << res[1][k - 1] << endl;
return 0;
}

BIN
S2OJ/1738/data/ex_sequence1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/ex_sequence1.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/ex_sequence2.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/ex_sequence2.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/ex_sequence3.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/ex_sequence3.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/problem.conf (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence1.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence10.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence10.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence11.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence11.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence12.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence12.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence13.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence13.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence14.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence14.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence15.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence15.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence16.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence16.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence17.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence17.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence18.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence18.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence19.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence19.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence2.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence2.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence20.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence20.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence21.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence21.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence22.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence22.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence23.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence23.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence24.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence24.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence25.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence25.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence26.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence26.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence27.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence27.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence28.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence28.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence29.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence29.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence3.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence3.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence4.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence4.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence5.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence5.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence6.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence6.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence7.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence7.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence8.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence8.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence9.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1738/data/sequence9.out (Stored with Git LFS) Normal file

Binary file not shown.