# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
143726 |
2019-08-15T01:12:54 Z |
Kanon |
Rectangles (IOI19_rect) |
C++14 |
|
15 ms |
4344 KB |
#include <bits/stdc++.h>
using namespace std;
#define range(i, m, n) for(int i = m; i < n; i++)
#define husk(i, m, n) for(int i = m; i > n; i--)
const int N = 2505;
vector<bitset<N>> bs(N);
struct sp {
bitset<N> st;
sp(){};
void add(int ss) {
st[ss] = 1;
}
int pos(int ss) {
return (st & bs[ss]).count();
}
sp operator ^ (const sp &a) const {
sp res;
res.st = st & a.st;
return res;
}
};
long long count_rectangles(vector<vector<int>> a) {
range(i, 0, N) range(j, 0, i) bs[i][j] = 1;
int m = a.front().size();
int n = a.size();
auto pos = [&] (vector<int> cur) {
int s = cur.size();
vector<pair<int, int>> res;
vector<int> st;
range(i, 0, s) {
while(st.size() && cur[st.back()] <= cur[i]) {
if(st.back() < i - 1) res.emplace_back(st.back() + 1, i - 1);
int b = st.back();
st.pop_back();
if(cur[b] == cur[i]) goto A;
}
if(st.size() && st.back() < i - 1) res.emplace_back(st.back() + 1, i - 1);
A:;
st.push_back(i);
}
return res;
};
vector<vector<sp>> cur(n, vector<sp>(m));
range(i, 0, n) {
vector<pair<int, int>> ss = pos(a[i]);
for(auto j : ss) {
cur[i][j.second].add(j.second - j.first);
}
}
long long res = 0;
vector<vector<pair<int, int>>> to(n, vector<pair<int, int>> (n, make_pair(-2, -2)));
range(i, 0, m) {
vector<int> psy(n);
range(j, 0, n) psy[j] = a[j][i];
vector<pair<int, int>> ss = pos(psy);
int sz = ss.size();
vector<sp> dp(sz);
vector<int> pr(n, -1);
range(j, 0, sz) {
int p = ss[j].second;
dp[j] = cur[p][i];
while(p >= ss[j].first) {
if(~pr[p]) {
dp[j] = dp[j] ^ dp[pr[p]];
p = ss[pr[p]].first - 1;
} else {
dp[j] = dp[j] ^ cur[p][i];
p--;
}
}
pr[ss[j].second] = j;
int l = to[ss[j].first][ss[j].second].second == i - 1 ? to[ss[j].first][ss[j].second].first : i;
if(l == i) to[ss[j].first][ss[j].second] = make_pair(i, i);
to[ss[j].first][ss[j].second].second = i;
res += dp[j].pos(j - l + 1);
}
}
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
12 ms |
2168 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
12 ms |
2168 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
12 ms |
2168 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
12 ms |
2168 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
15 ms |
4344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
11 ms |
2040 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
12 ms |
2168 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |