QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#292760#7120. Soccerdanielkou58550 479ms285016kbC++176.5kb2023-12-28 12:47:442024-04-28 08:13:59

Judging History

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

  • [2024-04-28 08:13:59]
  • 管理员手动重测本题所有提交记录
  • 测评结果:0
  • 用时:479ms
  • 内存:285016kb
  • [2023-12-28 12:47:45]
  • 评测
  • 测评结果:0
  • 用时:501ms
  • 内存:284992kb
  • [2023-12-28 12:47:44]
  • 提交

answer

// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()

using namespace std;

const int inf = (int) 1e9;

struct SegTree {
    vector<int> a;

	void resize(int N) {
		a.resize(4 * N);
		fill(all(a), inf);
	}

    int merge(int x, int y) {
        return min(x, y);
    }

    void update(int x, int l, int r, int idx, int val) {
        if (l == r) {
            a[x] = val;
            return;
        }

        int m = l + (r - l) / 2;

        if (idx <= m) {
            update(2 * x, l, m, idx, val);
        } else {
            update(2 * x + 1, m + 1, r, idx, val);
        }

        a[x] = merge(a[2 * x], a[2 * x + 1]);
    }

    int query(int x, int l, int r, int s, int e) {
        if (r < s || l > e) {
            return inf;
        }

        if (s <= l && r <= e) {
            return a[x];
        }

        int m = l + (r - l) / 2;

        return merge(query(2 * x, l, m, s, e), query(2 * x + 1, m + 1, r, s, e));
    }
};

vector<SegTree> one, two;

#define rectangel array<int, 4>

bool operator==(const rectangel &a, const rectangel &b) {
	for (int i = 0; i < 4; i++) {
		if (a[i] != b[i]) {
			return true;
		}
	}
   
    return false;
}

bool operator<(const rectangel &a, const rectangel &b) {
	if (a[1] - a[0] == b[1] - b[0]) {
		if (a[0] == b[0]) {
			if (a[1] == b[1]) {
				if (a[2] == b[2]) {
					return a[3] < b[3];
				}

				return a[2] < b[2];
			}

			return a[1] < b[1];
		}	

		return a[0] < b[0];
	}

	return a[1] - a[0] < b[1] - b[0];
}

using namespace std;

vector<rectangel> rects;

vector<vector<int>> up, down;

vector<vector<int>> what_is_this;
vector<vector<int>> nxt;

void add_edge_real(int N, int idx, vector<int> lst) {
	// cout << "u mom" << endl;
    for (int j = 0; j < sz(lst) - 1; j++) {
        if (lst[j + 1] - lst[j] <= 1) {
			continue;
		}

		rectangel another = {0, N - 1, lst[j] + 1, lst[j + 1] - 1};

        if (rects[idx][0] >= 1) {
			another[0] = -one[rects[idx][0] - 1].query(1, 0, N, another[2], another[3] + 1) + 1;
		}

        if (rects[idx][1] < N - 1) {
			another[1] = two[rects[idx][1] + 1].query(1, 0, N, another[2], another[3] + 1) - 1;
		}

        int pos = lower_bound(all(rects), another) - rects.begin();

        if (pos < sz(rects) && rects[pos] == another) { 
            nxt[idx].push_back(pos); 
        }
		// cout << "u mom" << endl;
    }
}

void add_edge(int N, int idx) {
	// cout << "u mom" << endl;
    if (rects[idx][0] >= 1) {
        int shambles = rects[idx][0] - 1;

        vector<int> updog; updog.push_back(rects[idx][2] - 1);

        int pos = lower_bound(all(what_is_this[shambles]), rects[idx][2]) - what_is_this[shambles].begin();
        
		while (pos < sz(what_is_this[shambles]) && what_is_this[shambles][pos] <= rects[idx][3]) {
            updog.push_back(what_is_this[shambles][pos]);

            pos++;
        }

        updog.push_back(rects[idx][3] + 1);
        add_edge_real(N, idx, updog);
    }

	// cout << "u mom" << endl;

    // Part 2
    if (rects[idx][1] < N - 1) {
        int shambles = rects[idx][1] + 1;

        vector<int> downdog; downdog.push_back(rects[idx][2] - 1);

        int pos = lower_bound(all(what_is_this[shambles]), rects[idx][2]) - what_is_this[shambles].begin();
        
		while (pos < sz(what_is_this[shambles]) && what_is_this[shambles][pos] <= rects[idx][3]) {
            downdog.push_back(what_is_this[shambles][pos]);
            
			pos++;
        }

        downdog.push_back(rects[idx][3] + 1);
        add_edge_real(N, idx, downdog);
    }
}

vector<int> dp;

int biggest_stadium(int N, vector<vector<int>> F) {
	up.resize(N); down.resize(N);

	for (int i = 0; i < N; i++) {
		up[i].resize(N);

		for (int j = 0; j < N; j++) {
			if (F[i][j]) {
				up[i][j] = i;
			} else if (i) {
				up[i][j] = up[i - 1][j];
			} else {
				up[i][j] = -1;
			}
		}
	}

	for (int i = N - 1; i >= 0; i--) {
		down[i].resize(N); // ur mom

		for (int j = 0; j < N; j++) {
			if (F[i][j]) {
				down[i][j] = i;
			} else if (i != N - 1) {
				down[i][j] = down[i + 1][j];
			} else {
				down[i][j] = N;
			}
		}
	}

	rects.clear();

	// make these shizzer rectengales
	for (int i = 0; i < N; i++) {
		vector<int> tmp1(N), tmp2(N, N);

		for (int j = 0; j < N; j++) {
			tmp1[j] = up[i][j];
		}

        if (i < N - 1) {
			// scuffed aaa aadlsfjasld;kfhasldk;fjasl;kjflakjsdflaksdjf;asdf ur mom
			for (int j = 0; j < N; j++) {
				tmp2[j] = down[i + 1][j];
			}
        }

		// for (int i = 0; i < N; i++) {
		// 	cout << tmp1[i] << " " << tmp2[i] << "\n";
		// }

		vector<pair<int, int>> stk; stk.push_back({-1, i + 2}); tmp1.push_back(i); // weird shit but trust

		int last = -1;

		for (int j = 0; j <= N; j++) {
			while (stk.back().second <= tmp1[j]) {
				auto v = stk.back().second; stk.pop_back();

				if (v == tmp1[j]) {
					continue;
				}

				// xl, xr, yl, yr
				rectangel r = {v + 1, i, stk.back().first + 1, j - 1};

				if (r[2] <= last) {
					rects.push_back(r);
				}
			}

			if (j == N) {
				break;
			}

			stk.push_back({j, tmp1[j]});

			if (tmp2[j] == i + 1) {
				last = j;
			}
		}
	}

	sort(all(rects));

	one.resize(N); two.resize(N);

	for (int i = 0; i < N; i++) {
		one[i].resize(N + 1);
		two[i].resize(N + 1);

		for (int j = 0; j < N; j++) {
			one[i].update(1, 0, N, j, -up[i][j]);
            two[i].update(1, 0, N, j, down[i][j]);
		}
	}

	what_is_this.resize(N); nxt.resize(N * N);

	for (int i = 0; i < N; i++) {
		what_is_this[i].clear(); nxt[i].clear(); 
	}

	for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (F[i][j]) {
				what_is_this[i].push_back(j);
			}
        }
    }

    for (int i = 0; i < sz(rects); i++) {
        add_edge(N, i);
    }

	// cout << sz(rects) << "\n";

	dp.resize(sz(rects));
	fill(dp.begin(), dp.end(), 0);

	// cout << "fuck" << endl;
    for (int i = 0; i < sz(rects); i++) {
        dp[i] = max(dp[i], (rects[i][1] - rects[i][0] + 1) * (rects[i][3] - rects[i][2] + 1));

        for (int n : nxt[i]) {
            int x = (rects[n][1] - rects[n][0] + 1) - (rects[i][1] - rects[i][0] + 1);
            int y = (rects[n][3] - rects[n][2] + 1);
            dp[n] = max(dp[n], dp[i] + x * y);
        }
    }

    int ans = 0;

    for (int i = 0; i < sz(rects); i++) {
		ans = max(ans, dp[i]);
	}

    return ans;
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 6
Accepted
time: 0ms
memory: 3872kb

input:

R0R7sb2atQWJ6SAWOjw4ZG7Gwgo5zl9L
1
0

output:

xlqtkQVzqzbOJxjzxlqsyVrlM2kqlbK0
OK
1

result:

ok ok

Test #2:

score: 1.5
Acceptable Answer
time: 0ms
memory: 3768kb

input:

R0R7sb2atQWJ6SAWOjw4ZG7Gwgo5zl9L
3
0 0 0
0 1 0
0 0 0

output:

xlqtkQVzqzbOJxjzxlqsyVrlM2kqlbK0
OK
3

result:

points 0.250 partial

Test #3:

score: 1.5
Acceptable Answer
time: 0ms
memory: 4608kb

input:

R0R7sb2atQWJ6SAWOjw4ZG7Gwgo5zl9L
100
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...

output:

xlqtkQVzqzbOJxjzxlqsyVrlM2kqlbK0
OK
9700

result:

points 0.250 partial

Test #4:

score: 1.5
Acceptable Answer
time: 18ms
memory: 21000kb

input:

R0R7sb2atQWJ6SAWOjw4ZG7Gwgo5zl9L
500
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...

output:

xlqtkQVzqzbOJxjzxlqsyVrlM2kqlbK0
OK
216000

result:

points 0.250 partial

Test #5:

score: 1.5
Acceptable Answer
time: 479ms
memory: 285016kb

input:

R0R7sb2atQWJ6SAWOjw4ZG7Gwgo5zl9L
2000
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 ...

output:

xlqtkQVzqzbOJxjzxlqsyVrlM2kqlbK0
OK
3458000

result:

points 0.250 partial

Test #6:

score: 0
Wrong Answer
time: 0ms
memory: 3820kb

input:

R0R7sb2atQWJ6SAWOjw4ZG7Gwgo5zl9L
9
1 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

output:

xlqtkQVzqzbOJxjzxlqsyVrlM2kqlbK0
OK
72

result:

wrong answer wrong

Subtask #2:

score: 0
Wrong Answer

Test #10:

score: 2
Acceptable Answer
time: 0ms
memory: 3816kb

input:

R0R7sb2atQWJ6SAWOjw4ZG7Gwgo5zl9L
3
0 0 0
0 1 0
0 1 1

output:

xlqtkQVzqzbOJxjzxlqsyVrlM2kqlbK0
OK
3

result:

points 0.250 partial

Test #11:

score: 2
Acceptable Answer
time: 1ms
memory: 3832kb

input:

R0R7sb2atQWJ6SAWOjw4ZG7Gwgo5zl9L
3
0 0 0
0 1 1
0 0 1

output:

xlqtkQVzqzbOJxjzxlqsyVrlM2kqlbK0
OK
3

result:

points 0.250 partial

Test #12:

score: 2
Acceptable Answer
time: 0ms
memory: 3860kb

input:

R0R7sb2atQWJ6SAWOjw4ZG7Gwgo5zl9L
3
0 0 1
0 0 0
1 1 0

output:

xlqtkQVzqzbOJxjzxlqsyVrlM2kqlbK0
OK
4

result:

points 0.250 partial

Test #13:

score: 2
Acceptable Answer
time: 0ms
memory: 3816kb

input:

R0R7sb2atQWJ6SAWOjw4ZG7Gwgo5zl9L
3
1 0 0
1 0 1
0 0 1

output:

xlqtkQVzqzbOJxjzxlqsyVrlM2kqlbK0
OK
3

result:

points 0.250 partial

Test #14:

score: 2
Acceptable Answer
time: 0ms
memory: 3820kb

input:

R0R7sb2atQWJ6SAWOjw4ZG7Gwgo5zl9L
3
0 0 1
0 0 0
1 0 0

output:

xlqtkQVzqzbOJxjzxlqsyVrlM2kqlbK0
OK
4

result:

points 0.250 partial

Test #15:

score: 0
Wrong Answer
time: 0ms
memory: 4132kb

input:

R0R7sb2atQWJ6SAWOjw4ZG7Gwgo5zl9L
3
0 0 1
0 0 1
0 0 0

output:

xlqtkQVzqzbOJxjzxlqsyVrlM2kqlbK0
OK
6

result:

wrong answer wrong

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Skipped

Dependency #4:

0%

Subtask #6:

score: 0
Skipped

Dependency #1:

0%