Skip to content

Commit

Permalink
5.16
Browse files Browse the repository at this point in the history
  • Loading branch information
dtcxzyw committed May 16, 2019
1 parent 89ffb57 commit 937859b
Show file tree
Hide file tree
Showing 12 changed files with 398 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"-D_FORTIFY_SOURCE=2",
"-ggdb3",
"-Wextra",
//"-ftrapv"
"-ftrapv"
]
},
"windows": {
Expand Down
2 changes: 1 addition & 1 deletion Checker/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ find_program(HAS_SYZOJTOOLS syzoj)

set (CHECKER_VERSION_MAJOR 2)
set (CHECKER_VERSION_MINOR 8)
set (CHECKER_VERSION_PATCH 3)
set (CHECKER_VERSION_PATCH 4)

option(BZOJ_JUDGER "bzoj-judger" ON)
option(LOJ_JUDGER "loj-judger" ON)
Expand Down
9 changes: 3 additions & 6 deletions Checker/Platforms/Linux/RunnerLinux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ static void runTask(const Option& opt,
{
struct rlimit limit;
flag &= getrlimit(RLIMIT_CPU, &limit) == 0;
limit.rlim_cur =
timer.remain() / 1000000LL + 1;
limit.rlim_cur = timer.remain() / 1000000LL;
flag &= setrlimit(RLIMIT_CPU, &limit) == 0;
}
if(!flag)
Expand Down Expand Up @@ -93,7 +92,8 @@ static RunResult watchTask(const Option& opt,
break;
} else if(WIFSIGNALED(status) ||
(WIFSTOPPED(status) &&
WSTOPSIG(status) != 5)) {
WSTOPSIG(status) != SIGTRAP &&
WSTOPSIG(status) != SIGXCPU)) {
res.st = Status::RE;
res.ret = RuntimeError::Unknown;
res.sig = WIFSIGNALED(status) ?
Expand All @@ -107,9 +107,6 @@ static RunResult watchTask(const Option& opt,
res.ret = RuntimeError::
FloatingPointError;
break;
case SIGXCPU:
res.st = Status::TLE;
break;
case SIGSEGV:
res.ret = RuntimeError::
SegmentationFault;
Expand Down
5 changes: 4 additions & 1 deletion Checker/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,12 @@ AC后询问OJ上的时间并加入samples中,在BZOJ计时方式下skip掉剩
2.8.2(4.11)
支持Windows下异常捕捉,使用Cmake支持自动更新

2.8.3(4.13)
2.8.3(5.13)
修复CheckerDir不一致的bug,扩大Adapters识别范围,增加perf开关

2.8.4(5.14)
修复系统时间超时产生SIGXCPU信号,误判TLE的问题。

## TODO List

- [x] 跨Windows平台、分离平台实现
Expand Down
4 changes: 2 additions & 2 deletions Queue.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@
- [ ] UOJ#274. 【清华集训2016】温暖会指引我们前行
- [x] BZOJ 3514
- [ ] bzoj2759(LCT维护基环树,做完加总结)
- [ ] bzoj4025
- [x] bzoj4025
# 平衡树
- [x] LOJ#516. 「LibreOJ β Round #2」DP 一般看规律
- [x] bzoj3545
Expand Down Expand Up @@ -294,7 +294,7 @@
- [ ] bzoj3834
- [x] bzoj3994
- [x] bzoj4407
- [ ] bzoj2813
- [x] bzoj2813
- [ ] bzoj4428
- [ ] UOJ450
- [ ] LOJ6072
Expand Down
2 changes: 1 addition & 1 deletion Review/DP/Mono.tex
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ \subsection{时间复杂度陷阱}
如遇到多轮相同的分治DP,则考虑将时间复杂度优化到与轮数无关。
否则容易被卡常/TLE。

例题:[Apio2014]序列分割(2019.4.8:调了一下午终于在bzoj上变成的rank1
例题:[Apio2014]序列分割(2019.4.8:调了一下午终于在bzoj上变成rank1

得出得分与序列切分顺序无关后就可以开始分治DP了。进一步考虑答案的实际表达式,
$b_i$为第$i$块的总和,有$ans=\frac{1}{2}\left(\left(\sum{b_i}\right)^2-min\sum{b_i^2}\right)$
Expand Down
File renamed without changes.
124 changes: 124 additions & 0 deletions Source/FWT FMT/LOJ154TLE.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
#include <cstdio>
#include <cstring>
#include <limits>
namespace IO {
char in[1 << 21];
void init() {
fread(in, 1, sizeof(in), stdin);
}
int getc() {
static char* S = in;
return *S++;
}
}
int read() {
int res = 0, c;
do
c = IO::getc();
while(c < '0' || c > '9');
while('0' <= c && c <= '9') {
res = res * 10 + c - '0';
c = IO::getc();
}
return res;
}
const int size = 1 << 21, mod = 998244353;
typedef long long Int64;
#define asInt64 static_cast<Int64>
int add(int a, int b) {
a += b;
return a < mod ? a : a - mod;
}
int sub(int a, int b) {
a -= b;
return a >= 0 ? a : a + mod;
}
void FWT(int* A, int end) {
for(int i = 1; i <= end; i <<= 1) {
int m = i >> 1;
for(int j = 0; j < end; j += i)
for(int k = 0; k < m; ++k) {
int &x = A[j + k + m], &y = A[j + k];
x = add(x, y);
}
}
}
void IFWT(int* A, int end) {
for(int i = 1; i <= end; i <<= 1) {
int m = i >> 1;
for(int j = 0; j < end; j += i)
for(int k = 0; k < m; ++k) {
int &x = A[j + k + m], &y = A[j + k];
x = sub(x, y);
}
}
}
typedef int(Arr)[22][size];
Arr A, B;
int bcnt[size], D[size];
void clear(Arr& S, int n) {
int end = 1 << n;
for(int k = 0; k <= n; ++k)
memset(S[k], 0, sizeof(int) * end);
}
const Int64 lim = std::numeric_limits<Int64>::max() -
asInt64(mod - 1) * (mod - 1);
Int64 C[size];
void conv(int* b, int n) {
int end = 1 << n;
clear(B, n);
for(int i = 0; i < end; ++i)
B[bcnt[i]][i] = b[i];
for(int i = 0; i <= n; ++i)
FWT(B[i], end);
for(int i = 0; i <= n; ++i) {
memset(C, 0, sizeof(Int64) * end);
for(int j = 0; j <= i; ++j) {
int *X = A[j], *Y = B[i - j];
for(int k = 0; k < end; ++k) {
C[k] += asInt64(X[k]) * Y[k];
if(C[k] > lim)
C[k] %= mod;
}
}
for(int k = 0; k < end; ++k)
D[k] = C[k] % mod;
IFWT(D, end);
for(int j = 0; j < end; ++j)
if(bcnt[j] == i)
b[j] = D[j];
}
}
int base[size], powv[size];
int main() {
IO::init();
int n = read();
int m = read();
int k = read();
int end = 1 << n;
for(int i = 0; i < end; ++i)
bcnt[i] = bcnt[i >> 1] + (i & 1);
for(int i = 1; i <= m; ++i)
++base[read()];
Int64 res = base[end - 1];

memcpy(powv, base, sizeof(int) * end);

for(int i = 0; i < end; ++i)
A[bcnt[i]][i] = base[i];
for(int i = 0; i <= n; ++i)
FWT(A[i], end);

Int64 inv[50];
inv[0] = inv[1] = 1;
for(int i = 2; i <= k; ++i)
inv[i] = (mod - mod / i) * inv[mod % i] % mod;
for(int i = 1; i <= k; ++i)
inv[i] = inv[i - 1] * inv[i] % mod;
for(int i = 2; i <= k; ++i) {
conv(powv, n);
res = (res + powv[end - 1] * inv[i]) % mod;
}
printf("%lld\n", res);
return 0;
}
File renamed without changes.
61 changes: 61 additions & 0 deletions Source/Number Theory/bzoj2813.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#include <cstdio>
const int size = 10000005, mod = 1000000007;
typedef long long Int64;
#define asInt64 static_cast<Int64>
int f[size], g[size], p[size], ffac[size], gfac[size],
d[size], pk[size];
bool flag[size];
void pre(int n) {
f[1] = g[1] = 1;
int pcnt = 0;
for(int i = 2; i <= n; ++i) {
if(!flag[i]) {
p[++pcnt] = i;
f[i] = ffac[i] = 2;

pk[i] = asInt64(i) * i % mod;
g[i] = gfac[i] = (1 + pk[i]) % mod;
d[i] = 1;
}
for(int j = 1; j <= pcnt && i * p[j] <= n;
++j) {
int val = i * p[j];
flag[val] = true;
if(i % p[j]) {
ffac[val] = ffac[p[j]];
f[val] = f[i] * ffac[val];

d[val] = i;
pk[val] = pk[p[j]];
gfac[val] = gfac[p[j]];
g[val] =
asInt64(g[i]) * gfac[val] % mod;
} else {
ffac[val] = ffac[i] + 1;
f[val] = f[i] / ffac[i] * ffac[val];

d[val] = d[i];
pk[val] =
asInt64(pk[i]) * pk[p[j]] % mod;
gfac[val] = (gfac[i] + pk[val]) % mod;
g[val] = asInt64(g[d[val]]) *
gfac[val] % mod;
break;
}
}
}
}
int main() {
int q, x, a, b, c;
scanf("%d%d%d%d%d", &q, &x, &a, &b, &c);
pre(c);
Int64 A = 0, B = 0;
for(int k = 1; k <= q; ++k) {
if(x & 1)
++A, B += 4;
A += f[x], B += g[x];
x = (asInt64(x) * a + b) % c + 1;
}
printf("%lld\n%lld\n", A % mod, B % mod);
return 0;
}
Loading

0 comments on commit 937859b

Please sign in to comment.