# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
144020 |
2019-08-15T17:05:37 Z |
Kanon |
Rectangles (IOI19_rect) |
C++14 |
|
86 ms |
1656 KB |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ordered_set tree<long long, null_type, greater<long long>, rb_tree_tag,tree_order_statistics_node_update>
#define range(i, m, n) for(int i = m; i < n; i++)
#define husk(i, m, n) for(int i = m; i > n; i--)
long long count_rectangles(vector<vector<int>> a) {
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<set<pair<int, int>>>> hp, vs;
hp.resize(n); for(auto &i : hp) i.resize(m);
vs.resize(n); for(auto &i : vs) i.resize(m);
range(i, 0, n) {
vector<pair<int, int>> foo = pos(a[i]);
for(auto u : foo) {
int l = u.first, r = u.second;
pair<int, int> p = make_pair(l, i);
if(i && hp[i - 1][r].lower_bound(make_pair(l, -1))->first == l) p.second = hp[i - 1][r].lower_bound(make_pair(l, -1))->second;
hp[i][r].insert(p);
}
}
range(i, 0, m) {
vector<int> ss(n);
range(j, 0, n) ss[j] = a[j][i];
vector<pair<int, int>> foo = pos(ss);
for(auto u : foo) {
int l = u.first, r = u.second;
pair<int, int> p = make_pair(l, i);
if(i && vs[r][i - 1].lower_bound(make_pair(l, -1))->first == l) p.second = vs[r][i - 1].lower_bound(make_pair(l, -1))->second;
vs[r][i].insert(p);
}
}
long long res = 0;
auto cnt = [&](set<pair<int, int>> &x, set<pair<int, int>> &y) {
cerr << x.size() << " " << y.size() << endl;
vector<pair<int, int>> sy;
for(auto i : y) {
swap(i.first, i.second);
sy.push_back(i);
}
sort(sy.begin(), sy.end());
reverse(sy.begin(), sy.end());
ordered_set cur;
auto it = x.end();
int p = sy.size() - 1;
while(it != x.begin()) {
it--;
while(~p && sy[p].first <= it->first) {
cur.insert(sy[p].second);
p--;
}
res += cur.order_of_key(it->second - 1);
}
};
range(i, 0, n) {
range(j, 0, m) {
cnt(hp[i][j], vs[i][j]);
}
}
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
secret mismatch |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
secret mismatch |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
secret mismatch |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
secret mismatch |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
86 ms |
1656 KB |
secret mismatch |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
256 KB |
secret mismatch |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
secret mismatch |
2 |
Halted |
0 ms |
0 KB |
- |