示例#1
0
文件: fort.cpp 项目: M4573R/pc-code
int solve()
{
    sort(sticks, sticks + N);
    int hi = sticks[N - 1];

    int ans = 0;
    tree.init(sticks[N - 1]);

    for (int i = N - 4; i >= 2; --i) {
        int a = i + 1;
        for (int b = a + 1; b < N; ++b)
            for (int c = b + 1; c < N; ++c) {
                int v = max(1, sticks[c] - (sticks[a] + sticks[b]));
                tree.add(v, 1);
            }

        for (int j = i - 1; j >= 1; --j)
            for (int k = j - 1; k >= 0; --k) {
                int v = min(hi, sticks[i] + sticks[j] + sticks[k]);
                ans += tree.query(v - 1);
            }
    }

    return ans;
}
示例#2
0
int main() {
    scanf("%d", &T);
    while (T--) {
        scanf("%d%d", &N, &M);

        bit.init(N + M);

        for (int i = 1; i <= N; i++) {
            bit.add(i, 1);
            no[i] = N + 1 - i;
        }

        for (int i = 1; i <= M; i++) {
            scanf("%d", &A[i]);
            printf("%d%c", N - bit.sum(no[A[i]]), i < M ? ' ' : '\n');

            bit.add(no[A[i]], -1);
            no[A[i]] = N + i;
            bit.add(no[A[i]], 1);
        }
    }

    return 0;
}
示例#3
0
文件: j.cpp 项目: M4573R/pc-code
int main()
{
	int T;
	scanf("%d", &T);

	int ncase = 0;
	while (T--) {
		scanf("%d", &N);
		tree.init(N);
		for (int i = 1; i <= N; ++i) {
			int x;
			scanf("%d", &x);
			tree.add(i, x);
		}

		printf("Case %d:\n", ++ncase);
		scanf("%d", &M);
		while (M--) {
			int cmd;
			scanf("%d", &cmd);
			if (cmd == 1) {
				int x, y;
				scanf("%d%d", &x, &y);
				printf("%d\n", tree.query(x, y));
			}
			else if (cmd == 2) {
				int x, y, p;
				scanf("%d%d%d", &x, &y, &p);
				tree.add(x, -p);
				tree.add(y, p);
			}
		}
	}

	return 0;
}
示例#4
0
文件: chart.cpp 项目: M4573R/pc-code
	void init(int n) {
		up.init(n);
		dn.init(n);
		nt.init(n);
	}