# codeforces 1093 题解

12.18 update：补充了 $F$ 题的题解

A 题：

B 题：

C 题：

D 题：

E 题：

F 题：

#include <bits/stdc++.h>
#define CIOS ios::sync_with_stdio(false);
#define rep(i, a, b) for(register int i = a; i <= b; i++)
#define per(i, a, b) for(register int i = a; i >= b; i--)
#define DEBUG(x) cerr << "DEBUG" << x << " >>> ";
using namespace std;

typedef unsigned long long ull;
typedef long long ll;

template <typename T>
f = 0; T fu = 1; char c = getchar();
while (c < '0' || c > '9') { if (c == '-') fu = -1; c = getchar(); }
while (c >= '0' && c <= '9') { f = (f << 3) + (f << 1) + (c & 15); c = getchar(); }
f *= fu;
}

template <typename T>
void print(T x) {
if (x < 0) putchar('-'), x = -x;
if (x < 10) putchar(x + 48);
else print(x / 10), putchar(x % 10 + 48);
}

template <typename T>
void print(T x, char t) {
print(x); putchar(t);
}

const int N = 1e5 + 5, md = 998244353;

inline int add(int x, int y) {
x += y;
if(x >= md) x -= md;
return x;
}

inline int sub(int x, int y) {
x -= y;
if(x < 0) x += md;
return x;
}

int f[N][105], cnt[N][105], s[N], a[N];
int n, k, len;

int main() {
for(register int i = 1; i <= n; i++) read(a[i]);
for(register int i = 1; i <= n; i++) {
for(register int j = 1; j <= k; j++) cnt[i][j] = cnt[i - 1][j] + (a[i] == -1 || a[i] == j);
}
s[0] = 1; if(a[1] == -1) { for(register int i = 1; i <= k; i++) f[1][i] = 1; s[1] = k; } else f[1][a[1]] = 1, s[1] = 1;
for(register int i = 2; i <= n; i++) {
for(register int j = 1; j <= k; j++) {
if(~a[i] && a[i] != j) continue;
f[i][j] = s[i - 1];
if(i >= len) {
int l = i - len;
if(cnt[i][j] - cnt[l][j] == len) {
f[i][j] = sub(f[i][j], sub(s[l], f[l][j]));
}
}
}
}
cout << s[n] << endl;
return 0;
}

G 题：

$31$ 的二进制表示是 $11111$，表示 $5$ 维的一个点的坐标加入的正负情况都为正（即 $x[1] - y[1] + x[2] - y[2] + x[3] - y[3] + x[4] - y[4] + x[5] - y[5]$

$29$ 的二进制表示是 $11101$，表示 $x[1] - y[1] + x[2] - y[2] + x[3] - y[3] - x[4] + y[4] + x[5] - y[5]$ （注意 $x[4]$ 和 $y[4]$ 的符号变化

posted @ 2018-12-17 19:40 LJC00118 阅读(...) 评论(...) 编辑 收藏