mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-27 17:16:28 +00:00
parent
b5de80fad1
commit
1470692777
87
NFLSOJ/0/3873/3873.cpp
Normal file
87
NFLSOJ/0/3873/3873.cpp
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
// #include <iostream>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <cstring>
|
||||||
|
#include <fstream>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
// using std::cin;
|
||||||
|
// using std::cout;
|
||||||
|
std::ifstream cin("monotony.in");
|
||||||
|
std::ofstream cout("monotony.out");
|
||||||
|
const char endl = '\n';
|
||||||
|
|
||||||
|
const int R = 15,
|
||||||
|
C = 105;
|
||||||
|
const int mod = 998244353;
|
||||||
|
|
||||||
|
int r, c, a[R][C], sum[C][1 << R], f[C][C], ans;
|
||||||
|
unsigned int op[C][C], st[C][C];
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
std::ios::sync_with_stdio(false);
|
||||||
|
cin.tie(nullptr);
|
||||||
|
|
||||||
|
cin >> r >> c;
|
||||||
|
|
||||||
|
for (int i = 1; i <= r; i++) {
|
||||||
|
for (int j = 1; j <= c; j++) {
|
||||||
|
cin >> a[i][j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int j = 1; j <= c; j++) {
|
||||||
|
for (int k = j + 1; k <= c; k++) {
|
||||||
|
for (int i = 1; i <= r; i++) {
|
||||||
|
if (a[i][j] < a[i][k]) {
|
||||||
|
op[j][k] |= 1 << (i - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int s = 0; s < (1 << r) - 1; s++) {
|
||||||
|
for (int j = 1; j <= c; ++j) {
|
||||||
|
for (int k = j + 1; k <= c; ++k) {
|
||||||
|
st[j][k] = op[j][k] & (((1 << r) - 1) ^ s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<int> b;
|
||||||
|
|
||||||
|
for (int i = 1; i <= c; i++) {
|
||||||
|
std::vector<int> v;
|
||||||
|
|
||||||
|
for (int j = 1; j <= r; j++) {
|
||||||
|
if (s & (1 << j - 1)) continue;
|
||||||
|
|
||||||
|
v.emplace_back(a[j][i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (std::is_sorted(v.begin(), v.end()) || std::is_sorted(v.rbegin(), v.rend())) {
|
||||||
|
b.emplace_back(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < b.size(); i++) {
|
||||||
|
for (int j = 0; j < i; j++) {
|
||||||
|
int c = st[b[j]][b[i]];
|
||||||
|
f[i][j] = (sum[j][c] + 1) % mod;
|
||||||
|
sum[i][c] = (static_cast<long long>(sum[i][c]) + f[i][j]) % mod;
|
||||||
|
ans = (static_cast<long long>(ans) + f[i][j]) % mod;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < b.size(); i++) {
|
||||||
|
for (int j = 0; j < i; j++) {
|
||||||
|
f[i][j] = 0;
|
||||||
|
sum[i][st[b[j]][b[i]]] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ans = (static_cast<long long>(ans) + b.size()) % mod;
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << ans << endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
BIN
NFLSOJ/0/3873/data/monotony03.in
(Stored with Git LFS)
Normal file
BIN
NFLSOJ/0/3873/data/monotony03.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
NFLSOJ/0/3873/data/monotony03.out
(Stored with Git LFS)
Normal file
BIN
NFLSOJ/0/3873/data/monotony03.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
NFLSOJ/0/3873/samples/monotony1.ans
(Stored with Git LFS)
Normal file
BIN
NFLSOJ/0/3873/samples/monotony1.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
NFLSOJ/0/3873/samples/monotony1.in
(Stored with Git LFS)
Normal file
BIN
NFLSOJ/0/3873/samples/monotony1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
NFLSOJ/0/3873/samples/monotony2.ans
(Stored with Git LFS)
Normal file
BIN
NFLSOJ/0/3873/samples/monotony2.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
NFLSOJ/0/3873/samples/monotony2.in
(Stored with Git LFS)
Normal file
BIN
NFLSOJ/0/3873/samples/monotony2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user