QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#291138#6222. 精准预测MoRanSky100 ✓1030ms92048kbC++232.8kb2023-12-26 05:02:102023-12-26 05:02:10

Judging History

你现在查看的是最新测评结果

  • [2023-12-26 05:02:10]
  • 评测
  • 测评结果:100
  • 用时:1030ms
  • 内存:92048kb
  • [2023-12-26 05:02:10]
  • 提交

answer

// Skyqwq
#include <bits/stdc++.h>

#define pb push_back
#define fi first
#define se second
#define mp make_pair

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

template <typename T> bool chkMax(T &x, T y) { return (y > x) ? x = y, 1 : 0; }
template <typename T> bool chkMin(T &x, T y) { return (y < x) ? x = y, 1 : 0; }

template <typename T> void inline read(T &x) {
    int f = 1; x = 0; char s = getchar();
    while (s < '0' || s > '9') { if (s == '-') f = -1; s = getchar(); }
    while (s <= '9' && s >= '0') x = x * 10 + (s ^ 48), s = getchar();
    x *= f;
}

const int N = 5e4 + 5, S = 6e5 + 5;

int T, n, m, idx = 1, ti[S], st[N], ed[N], in[S], deg[S], q[S], hh, tt;

int A[S], B[S], len;

vector<int> id[N];

map<int, int> M[N];

bool ban[S];

int ans[N], sp;

int inline get(int x, int t) {
	if (M[x].count(t)) return M[x][t];
	M[x][t] = ++idx;
	ti[idx] = t;
	id[x].pb(idx);
	++idx;
	return M[x][t];
}

vector<int> g[S], e[S];

void inline add(int x, int y) {
	g[x].pb(y), e[y].pb(x), in[x]++;
}

int inline get(int x, int t, int o) {
	return get(x, t) + o;
}

bool inline cmp1(int x, int y) {
	return ti[x] < ti[y];
}

bool vis[S], ok[S];

void dfs(int u) {
	vis[u] = 1;
	for (int v: g[u])
		if (!vis[v]) dfs(v);
}

int L, R;

typedef unsigned long long ULL;

void inline toposort() {
	hh = 1, tt = 0;
	for (int i = 2; i <= idx; i++)
		if (!in[i]) q[++tt] = i;
	while (hh <= tt) {
		int u = q[hh++];
		for (int v: e[u]) {
			A[++len] = u, B[len] = v;
			if (--in[v] == 0) q[++tt] = v;
		}
	}
}

ULL d[S];

void inline work() {
	for (int i = 2; i <= idx; i++) d[i] = 0;
	for (int i = L; i <= R; i++)
		d[ed[i]] |= 1ull << (i - L);
	for (int i = 1; i <= len; i++) {
		d[B[i]] |= d[A[i]];
	}
	
	ULL od = 0;
	for (int i = L; i <= R; i++)
		if (d[ed[i] + 1] >> (i - L) & 1) ban[i] = 1, od |= 1ull << (i - L);
	for (int i = 1; i <= n; i++) {
		ans[i] += __builtin_popcountll(d[ed[i] + 1] | od);
	}
}

int main() {
	read(T), read(n), read(m);
	while (m--) {
		int op, t, x, y; read(op), read(t), read(x), read(y);
		if (!op) {
			add(get(x, t, 0), get(y, t + 1, 0));
			add(get(y, t + 1, 1), get(x, t, 1));
		} else {
			add(get(x, t, 1), get(y, t, 0));
			add(get(y, t, 1), get(x, t, 0));
		}
	}
	for (int i = 1; i <= n; i++) {
		ed[i] = get(i, T + 1);
	}
	for (int i = 1; i <= n; i++) {
		sort(id[i].begin(), id[i].end(), cmp1);
		for (int j = 0; j + 1 < id[i].size(); j++) {
			add(id[i][j], id[i][j + 1]);
			add(id[i][j + 1] + 1, id[i][j] + 1);
		}
	}
	toposort();
	for (int u = 1; u <= n; u += 64) {
		L = u, R = min(u + 64 - 1, n);
		work();
	}
	for (int i = 1; i <= n; i++) {
		if (ban[i]) printf("0 ");
		else printf("%d ", n - 1 - ans[i]);
	}
    return 0;
}

详细

Test #1:

score: 10
Accepted
time: 4ms
memory: 46892kb

input:

2 10 10
0 1 5 3
0 1 10 10
1 1 4 4
1 1 10 3
0 1 2 5
1 1 8 1
1 1 10 8
0 1 2 2
1 2 10 3
1 2 8 3

output:

7 8 6 0 8 8 8 5 8 6 

result:

ok 10 numbers

Test #2:

score: 10
Accepted
time: 4ms
memory: 50948kb

input:

100 100 200
1 98 31 73
0 75 20 71
1 61 95 74
1 33 42 5
0 70 67 67
1 46 27 80
1 80 70 62
0 34 25 97
1 58 7 43
1 23 26 10
0 8 86 59
0 85 51 41
1 8 54 72
0 7 59 29
0 8 31 9
0 92 88 3
0 34 31 50
1 63 85 90
0 85 66 69
0 32 45 71
1 47 21 21
0 58 2 16
0 14 17 84
1 32 12 10
0 11 40 31
0 70 85 67
0 36 35 84
...

output:

90 85 83 88 85 90 89 82 89 81 89 0 88 90 0 84 84 91 91 85 0 90 88 85 90 88 86 0 85 85 88 84 89 88 86 88 85 88 88 87 86 86 81 90 90 84 0 90 75 0 90 85 89 89 91 86 87 87 88 85 88 90 85 90 88 84 0 89 85 84 85 82 84 84 89 84 89 91 83 85 87 89 87 80 82 90 0 89 90 88 87 90 87 91 86 90 86 85 78 90 

result:

ok 100 numbers

Test #3:

score: 10
Accepted
time: 8ms
memory: 51068kb

input:

100 100 200
0 18 72 87
0 26 100 8
1 2 84 58
1 90 92 65
0 31 23 62
1 69 70 52
1 87 74 45
0 71 1 17
1 2 64 54
1 51 43 62
0 3 17 44
1 18 41 27
0 21 67 30
1 67 76 22
0 66 76 59
1 53 49 78
0 96 47 49
1 52 78 95
0 59 73 60
1 20 64 40
0 39 20 70
0 46 63 69
0 62 8 14
0 6 33 47
1 52 39 45
1 11 70 30
0 86 26 ...

output:

91 88 98 99 92 94 98 96 96 98 96 98 97 95 96 95 85 97 89 98 95 97 92 99 96 93 93 94 98 94 98 93 91 98 96 91 99 89 89 86 89 96 92 96 93 94 85 95 82 91 96 98 90 93 96 97 91 90 94 92 91 95 95 89 96 93 99 98 99 87 98 94 95 96 93 97 96 95 93 88 90 94 99 86 95 91 97 92 87 96 85 94 99 98 92 93 96 95 99 92 

result:

ok 100 numbers

Test #4:

score: 10
Accepted
time: 7ms
memory: 50692kb

input:

1000000 3000 6000
0 1 1 1860
0 1 2 51
0 1 3 61
0 1 4 2721
0 1 5 596
0 1 6 2173
0 1 7 974
0 1 8 1525
0 1 9 706
0 1 10 451
0 1 11 2075
0 1 12 812
0 1 13 1117
0 1 14 299
0 1 15 2099
0 1 16 1521
0 1 17 2285
0 1 18 375
0 1 19 2894
0 1 20 1208
0 1 21 614
0 1 22 924
0 1 23 1670
0 1 24 867
0 1 25 2291
0 1 2...

output:

1495 1495 1496 1496 1497 1498 1497 1497 1495 1497 1497 1498 1497 1497 1497 1495 1497 1496 1497 1496 1496 1496 1496 1496 1497 1495 1496 1498 1497 1498 1495 1497 1497 1496 1496 1496 1496 1497 1497 1498 1496 1497 1497 1497 1496 1497 1496 1496 1497 1496 1496 1497 1496 1496 1496 1496 1496 1498 1497 1496 ...

result:

ok 3000 numbers

Test #5:

score: 10
Accepted
time: 41ms
memory: 55848kb

input:

40000 10000 20000
1 1 1 1
0 1 1 2
0 1 1 3
0 2 3 4
0 2 3 5
0 3 5 6
0 3 5 7
0 4 7 8
0 4 7 9
0 5 9 10
0 5 9 11
0 6 11 12
0 6 11 13
0 7 13 14
0 7 13 15
0 8 15 16
0 8 15 17
0 9 17 18
0 9 17 19
0 10 19 20
0 10 19 21
0 11 21 22
0 11 21 23
0 12 23 24
0 12 23 25
0 13 25 26
0 13 25 27
0 14 27 28
0 14 27 29
0 ...

output:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 10000 numbers

Test #6:

score: 10
Accepted
time: 45ms
memory: 58816kb

input:

40000 10000 20000
0 39999 2589 1050
1 39998 2589 983
0 39999 4308 9484
1 39998 4308 2423
0 39999 7924 4021
1 39998 7924 5520
0 39999 8340 2926
1 39998 8340 5694
0 39999 4146 8898
1 39998 4146 8588
0 39999 3838 2397
1 39998 3838 4545
0 39996 9766 4308
1 39995 9766 6570
0 39996 4764 8340
1 39995 4764 ...

output:

7771 7766 0 0 7771 7769 0 0 7763 7770 7762 7771 7766 7770 7738 0 7772 7766 7765 0 0 7772 7772 7759 7768 7750 7766 7692 7767 7766 7764 7771 7751 0 7744 7747 0 0 0 7772 7771 7771 7759 0 7719 7752 7771 7738 0 7763 7770 0 7760 0 7769 7770 0 7766 0 7762 7764 7770 7764 7763 0 7764 7765 7771 7771 7769 7751...

result:

ok 10000 numbers

Test #7:

score: 10
Accepted
time: 367ms
memory: 78572kb

input:

1000000 30000 60000
0 999999 18959 18261
1 999998 18959 19279
0 999996 6700 18959
1 999995 6700 2151
0 999996 19778 18959
1 999995 19778 12268
0 999993 8449 6700
1 999992 8449 29787
0 999993 14350 6700
1 999992 14350 21702
0 999993 9759 6700
1 999992 9759 23907
0 999990 18560 9759
1 999989 18560 227...

output:

23311 23323 0 0 23319 0 23318 23322 23324 23301 23322 23324 23324 23318 23314 23308 23325 23295 23307 23314 23315 23324 23322 0 23318 23321 23323 23324 23312 0 23314 23322 23316 0 23322 23324 0 23325 23325 0 23319 23324 23315 23321 23317 23316 23324 23322 23322 23311 0 0 0 23319 0 23321 23293 23318 ...

result:

ok 30000 numbers

Test #8:

score: 10
Accepted
time: 605ms
memory: 82148kb

input:

1000000 40000 80000
1 1 1 1
0 1 1 2
0 1 1 3
0 2 3 4
0 2 3 5
0 3 5 6
0 3 5 7
0 4 7 8
0 4 7 9
0 5 9 10
0 5 9 11
0 6 11 12
0 6 11 13
0 7 13 14
0 7 13 15
0 8 15 16
0 8 15 17
0 9 17 18
0 9 17 19
0 10 19 20
0 10 19 21
0 11 21 22
0 11 21 23
0 12 23 24
0 12 23 25
0 13 25 26
0 13 25 27
0 14 27 28
0 14 27 29
...

output:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 40000 numbers

Test #9:

score: 10
Accepted
time: 1030ms
memory: 92048kb

input:

1000000 50000 100000
0 999999 18845 16698
1 999998 18845 7793
0 999999 30202 25942
1 999998 30202 39321
0 999999 10014 42307
1 999998 10014 16269
0 999999 5779 8262
1 999998 5779 48787
0 999996 38679 5779
1 999995 38679 17636
0 999996 33436 5779
1 999995 33436 7042
0 999996 11608 5779
1 999995 11608...

output:

38863 38873 38871 38862 38875 38855 38864 38876 38871 38876 38874 38849 38876 38869 38873 0 38876 38874 38871 38868 38870 38870 38873 38866 38863 0 38869 38869 0 0 38876 38846 38862 38858 38872 38873 38868 38872 38872 38874 38876 0 38870 38876 0 0 38875 38840 0 38872 38870 38873 38875 38870 38860 38...

result:

ok 50000 numbers

Test #10:

score: 10
Accepted
time: 816ms
memory: 82172kb

input:

1000000 50000 100000
0 1 1 41380
0 1 2 36609
0 1 3 25332
0 1 4 39173
0 1 5 37591
0 1 6 49880
0 1 7 33261
0 1 8 29353
0 1 9 33900
0 1 10 3182
0 1 11 38944
0 1 12 8610
0 1 13 4518
0 1 14 21812
0 1 15 325
0 1 16 47816
0 1 17 21494
0 1 18 14930
0 1 19 2669
0 1 20 46226
0 1 21 17334
0 1 22 1388
0 1 23 29...

output:

24998 24998 24998 24998 24997 24997 24998 24998 24996 24996 24998 24999 24997 24998 24997 24998 24996 24999 24999 24999 24996 24999 24998 24998 24997 24997 24998 24998 24998 24998 24997 24998 24996 24998 24997 24997 24997 24998 24999 24999 24996 24997 24997 24997 24996 24996 24998 24998 24998 24998 ...

result:

ok 50000 numbers

Extra Test:

score: 0
Extra Test Passed