QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#182810 | #3503. Misspelling | ClHg2 | 0 | 1ms | 3468kb | C++14 | 1.6kb | 2023-09-18 16:13:56 | 2023-09-18 16:13:57 |
answer
#include <algorithm>
#include <cstdint>
#include <iostream>
#define EVAL(x) cout << #x " = " << x << "\n"
namespace {
using std::cin;
using std::cout;
using std::int64_t;
const int kP = 998244353;
namespace mod {
inline int Mod(int x) { return x >= kP ? x - kP : x; }
inline void Add(int &x, int y) { x = Mod(x + y); }
} // namespace mod
const int kMaxN = 5.0e5 + 5;
int n, m;
int lt_bound[kMaxN], gt_bound[kMaxN];
int f[kMaxN][26];
} // namespace
int main() {
cin.tie(nullptr);
std::ios::sync_with_stdio(false);
cin >> n >> m;
while (m--) {
int a, b;
cin >> a >> b;
if (a < b) {
gt_bound[a] = std::max(gt_bound[a], b - 1);
} else {
lt_bound[b] = std::max(lt_bound[b], a - 1);
}
}
std::fill_n(f[0], 26, 1);
for (int i = 0; i < n - 1; ++i) {
for (int c = 0; c < 26; ++c) {
// EVAL(i), EVAL(c), EVAL(f[i][c]);
for (int next_c = 0; next_c < 26; ++next_c) {
if (c == next_c) continue;
if (c < next_c) {
int max = 0;
for (int j = i + 1; j <= n - 1; ++j) {
max = std::max(max, gt_bound[j]);
if (j > max) mod::Add(f[j][next_c], f[i][c]);
}
} else {
int max = 0;
for (int j = i + 1; j <= n - 1; ++j) {
max = std::max(max, lt_bound[j]);
if (j > max) mod::Add(f[j][next_c], f[i][c]);
}
}
}
}
}
int ans = 0;
for (int i = 0; i <= n - 1; ++i) {
for (int c = 0; c < 26; ++c) mod::Add(ans, f[i][c]);
}
cout << ans << "\n";
return 0;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 8
Accepted
time: 1ms
memory: 3436kb
input:
10 9 3 4 4 2 6 2 7 6 7 8 8 5 5 10 10 9 9 1
output:
344750796
result:
ok single line: '344750796'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3444kb
input:
10 9 3 7 7 4 4 9 6 9 8 6 8 5 5 10 10 1 1 2
output:
1506401
result:
ok single line: '1506401'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3448kb
input:
10 10 2 8 1 5 9 3 3 9 2 9 7 10 7 3 7 8 4 1 5 6
output:
351
result:
ok single line: '351'
Test #4:
score: 0
Accepted
time: 1ms
memory: 3468kb
input:
10 90 5 2 4 2 3 6 1 10 7 1 10 9 1 7 2 3 10 3 7 6 8 5 5 3 9 1 6 3 8 1 3 5 6 2 5 1 2 10 2 8 8 7 3 4 6 7 3 10 4 8 7 3 1 8 2 9 9 2 3 2 9 6 2 1 1 9 1 5 8 3 4 5 8 10 4 3 9 8 2 6 10 2 3 7 4 9 8 9 7 5 5 7 10 5 9 4 1 4 10 7 9 10 9 7 6 10 7 9 2 4 5 9 2 7 1 3 3 9 6 9 2 5 6 1 9 3 7 10 5 10 8 4 8 6 3 8 8 2 3 1 5...
output:
26
result:
ok single line: '26'
Test #5:
score: -8
Wrong Answer
time: 1ms
memory: 3440kb
input:
10 1 4 2
output:
282234340
result:
wrong answer 1st lines differ - expected: '960864167', found: '282234340'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Time Limit Exceeded
Test #19:
score: 0
Time Limit Exceeded
input:
500000 499999 5 6 6 7 7 11 11 15 15 18 18 20 20 21 21 22 22 23 23 27 27 28 28 29 29 30 30 32 32 33 33 35 35 36 36 37 37 43 43 44 44 46 46 47 47 48 48 49 49 51 51 52 52 53 53 54 54 58 58 61 61 63 63 64 64 65 65 66 66 69 69 70 70 76 76 77 77 78 78 80 80 81 81 83 83 87 87 88 88 90 90 92 92 93 93 96 96 ...
output:
result:
Subtask #4:
score: 0
Skipped
Dependency #2:
0%
Subtask #5:
score: 0
Skipped
Dependency #1:
0%