Submission #293709

#TimeUsernameProblemLanguageResultExecution timeMemory
293709egekabasRectangles (IOI19_rect)C++14
10 / 100
2 ms416 KiB
#include "rect.h" #include <bits/stdc++.h> #define all(x) (x).begin(), (x).end() #define ff first #define ss second #define pb push_back #define mp make_pair using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<ll, ll> pll; typedef pair<ull, ull> pull; typedef pair<int, int> pii; typedef pair<ld, ld> pld; int n, m; ll solven3(vector<std::vector<int> > a){ vector<int> bad; for(int i = 0; i < m; ++i) if(a[1][i] >= a[0][i] || a[1][i] >= a[2][i]){ bad.pb(i); } vector<pii> vec; ll ans = 0; for(int i = m-1; i >= 0; --i){ while(vec.size()){ int idx1 = upper_bound(all(bad), i)-bad.begin(); int idx2 = int(lower_bound(all(bad), vec.back().ss)-bad.begin())-1; if(idx1 > idx2 && vec.back().ss != i+1) ++ans; if(vec.back().ff > a[1][i]) break; vec.pop_back(); } vec.pb({a[1][i], i}); } return ans; } long long count_rectangles(vector<std::vector<int> > a) { n = a.size(); m = a[0].size(); if(n == 3) return solven3(a); else return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...