Submission #1060802

# Submission time Handle Problem Language Result Execution time Memory
1060802 2024-08-15T23:02:15 Z jamesbamber Rectangles (IOI19_rect) C++17
72 / 100
5000 ms 741096 KB
#include "rect.h"
#include <bits/stdc++.h>
#pragma GCC target("avx2")
using namespace std;

struct segment{
	vector<short> tr;
	int sz;

	segment(vector<int> &v){
		sz = 1;
		while(sz <= v.size()) sz *= 2;
		tr.resize(2*sz);

		for(int i=0; i<v.size(); i++) tr[i+sz] = v[i];
		for(int i=sz; --i;) tr[i] = max(tr[2*i], tr[2*i+1]); 
	}
	segment() {}

	int query(int l, int r){
		short ans = 0;
		for(l+=sz, r+=sz; l<r; l>>=1, r>>=1){
			if(l & 1) ans = max(ans, tr[l++]);
			if(r & 1) ans = max(ans, tr[--r]);
		}
		return ans;
	}
};

struct segment2d{
	vector<segment> tr;
	int sz;

	segment2d(vector<vector<int>> &v){
		sz = 1;
		while(sz <= v.size()) sz *= 2;
		tr.resize(2*sz);

		int sz2 = v[0].size();

		vector<int> ilvuoto(sz2);

		for(int i=0; i<v.size(); i++) tr[i+sz] = segment(v[i]);
		for(int i=v.size(); i<sz; i++) tr[i+sz] = segment(ilvuoto);
		for(int i=sz; --i;){
			vector<int> treesus(sz2);
			for(int j=0; j<sz2; j++) treesus[j] = max(tr[2*i].tr[j+tr[2*i].sz], tr[2*i+1].tr[j+tr[2*i+1].sz]); 
			tr[i] = segment(treesus);
		}
	}

	int query(int l, int r, int ql, int qr){
		int ans = 0;
		for(l+=sz, r+=sz; l<r; l>>=1, r>>=1){
			if(l & 1) ans = max(ans, tr[l++].query(ql, qr));
			if(r & 1) ans = max(ans, tr[--r].query(ql, qr));
		}
		return ans;
	}
};

struct segment2{
	vector<short> tr;
	int sz;

	segment2(vector<int> &v){
		sz = 1;
		while(sz <= v.size()) sz *= 2;
		tr.resize(2*sz);

		for(int i=0; i<v.size(); i++) tr[i+sz] = v[i];
		for(int i=v.size(); i<sz; i++) tr[i+sz] = 1e4;
		for(int i=sz; --i;) tr[i] = min(tr[2*i], tr[2*i+1]); 
	}
	segment2() {}

	int query(int l, int r){
		short ans = 1e4;
		for(l+=sz, r+=sz; l<r; l>>=1, r>>=1){
			if(l & 1) ans = min(ans, tr[l++]);
			if(r & 1) ans = min(ans, tr[--r]);
		}
		return ans;
	}
};

struct segment22d{
	vector<segment2> tr;
	int sz;

	segment22d(vector<vector<int>> &v){
		sz = 1;
		while(sz <= v.size()) sz *= 2;
		tr.resize(2*sz);

		int sz2 = v[0].size();

		vector<int> ilgrosso(sz2, 1e9);

		for(int i=0; i<v.size(); i++) tr[i+sz] = segment2(v[i]);
		for(int i=v.size(); i<sz; i++) tr[i+sz] = segment2(ilgrosso);
		for(int i=sz; --i;){
			vector<int> treesus(sz2, 1e9);
			for(int j=0; j<sz2; j++) treesus[j] = min(tr[2*i].tr[j+tr[2*i].sz], tr[2*i+1].tr[j+tr[2*i+1].sz]); 
			tr[i] = segment2(treesus);
		}
	}

	int query(int l, int r, int ql, int qr){
		int ans = 1e9;
		for(l+=sz, r+=sz; l<r; l>>=1, r>>=1){
			if(l & 1) ans = min(ans, tr[l++].query(ql, qr));
			if(r & 1) ans = min(ans, tr[--r].query(ql, qr));
		}
		return ans;
	}
};

long long count_rectangles(vector<vector<int>> a) {
	int n = a.size();
	int m = a[0].size();

	vector<vector<int>> up(n, vector<int>(m, -1)), down(n, vector<int>(m, n)), left(n, vector<int>(m, -1)), right(n, vector<int>(m, m));

	//right
	for(int i=0; i<n; i++){
		stack<int> s;
		for(int j=0; j<m; j++){
			while(s.size() and a[i][s.top()] < a[i][j]){
				right[i][s.top()] = j;
				s.pop();
			}
			s.push(j);
		}
	}

	//left
	for(int i=0; i<n; i++){
		stack<int> s;
		for(int j=m-1; j>=0; j--){
			while(s.size() and a[i][s.top()] < a[i][j]){
				left[i][s.top()] = j;
				s.pop();
			}
			s.push(j);
		}
	}

	//up
	for(int j=0; j<m; j++){
		stack<int> s;
		for(int i=n-1; i>=0; i--){
			while(s.size() and a[s.top()][j] < a[i][j]){
				up[s.top()][j] = i;
				s.pop();
			}
			s.push(i);
		}
	}

	//down
	for(int j=0; j<m; j++){
		stack<int> s;
		for(int i=0; i<n; i++){
			while(s.size() and a[s.top()][j] < a[i][j]){
				down[s.top()][j] = i;
				s.pop();
			}
			s.push(i);
		}
	}

	int ans = 0;

	vector<array<int, 4>> grind;

	segment2d stright(right), stdown(down);
	segment22d stleft(left), stup(up);
	for(int i=1; i<n-1; i++){
		for(int j=1; j<m-1; j++){
			int l = left[i][j], r = right[i][j], u = up[i][j], d = down[i][j];
			if(l == -1 or r == m or u == -1 or d == n) continue;
			if(
				u == stup.query(u+1, d, l+1, r) and 
				r == stright.query(u+1, d, l+1, r) and 
				l == stleft.query(u+1, d, l+1, r) and 
				d == stdown.query(u+1, d, l+1, r)
			) grind.push_back({l, r, u, d});
			// cerr << i << " " << j << endl;
			// cerr << l << " " << r << " " << u << " " << d << endl;
			// cerr << stleft.query(u+1, d, l+1, r) << " " << stright.query(u+1, d, l+1, r) << " " << stup.query(u+1, d, l+1, r) << " " << stdown.query(u+1, d, l+1, r) << endl;
		}
	}

	// for(int i=0; i<n; i++){
	// 	for(int j=0; j<m; j++){
	// 		cout << left[i][j] << " ";
	// 	}
	// 	cout << endl;
	// }

	sort(grind.begin(), grind.end());
	return unique(grind.begin(), grind.end()) - grind.begin();
}

/*
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣀⣠⣤⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣤⡴⡖⣻⡟⣛⡛⣿⣿⣿⣿⣻⣿⣿⡟⠛⠳⣦⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣾⣿⣯⣾⣤⣹⣷⣿⣿⡿⣿⡿⣿⣿⣿⣿⣼⣧⣄⣚⠉⠛⠶⢶⣤⣀⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣗⣙⠾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢘⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠿⠿⠿⠛⠛⠛⠛⠿⠿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧⣀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣾⣿⣿⣿⣿⣿⡿⠛⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠙⠻⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣿⣿⣿⣿⣿⠟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠙⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡆⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠸⣿⣿⣿⣯⡿⠀⠀⠀⠀⠀⠀⠀⠠⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡀⢀⣀⣄⡀⠀⠀⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣿⣿⣿⣿⡇⣠⣾⣿⣿⣶⣶⣶⣶⣿⣦⡀⠀⠻⣤⣶⣾⣿⣿⣿⣿⣿⠿⠿⣿⣶⣄⠈⣿⡇⢹⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣿⣿⣿⣿⣿⠁⡿⠟⣉⣽⣿⣿⣿⣿⣿⣿⡗⠀⠀⢈⣿⣿⣿⣿⣿⣿⣿⣷⣾⣿⣿⣿⣦⣹⡇⣽⣿⣿⣿⣿⣿⣿⣿⠀⣀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⢀⠴⠂⠀⣀⣤⣾⣿⣿⣿⣿⣿⡿⠀⢱⣿⣿⣏⣛⣛⣣⢬⣹⢿⠏⠀⢀⣼⣿⣯⡛⠒⢽⣿⣥⡿⣿⣿⣿⣿⣿⣿⣇⣿⣿⣿⣿⣿⣿⣿⣍⣉⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⣰⣿⠤⣶⣿⠿⣻⣿⣿⣿⣿⣿⣿⡇⠀⠀⠋⠀⠉⠉⠁⠒⠉⠀⠀⡀⠀⠀⢿⣿⣿⠛⠦⠀⠀⢸⡿⠋⠋⠙⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⡛⣆⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠈⠉⠉⢡⣰⣥⠾⣿⣿⣿⣿⣿⣿⣿⣿⡅⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡾⠁⠀⠀⢸⡿⣿⡀⠀⠀⠀⠀⠀⠀⠀⠀⣰⣾⣿⣿⣿⣿⡹⣿⣿⣿⣿⣿⣿⣦⡀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⢀⡕⠽⣾⣿⣿⣿⣿⣿⣿⣿⣿⣧⠀⠀⠀⠀⠀⠀⠀⠀⢠⣿⣶⣶⣤⣶⣿⣷⣼⣧⡀⠀⠀⠀⠠⠀⢀⣰⣿⣿⣿⣿⣿⣿⣷⣻⣿⣿⣿⣿⣿⣿⢿⣿⣶⠄
⠀⠀⠀⠀⠀⠀⠀⠀⡞⠀⢀⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣆⠀⠀⠀⠀⠀⠀⢠⠎⠻⠯⣍⠙⠟⢻⣿⠿⣿⠟⠀⠀⠀⣶⣦⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣟⠳⣌⢣⠀
⠀⠀⠀⠀⠀⠀⠀⠀⣡⠖⠙⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡀⠀⠀⠀⠀⠀⠈⠀⢀⣴⣿⠟⠁⢾⣿⣷⣄⡀⡀⠀⠀⠿⠟⢹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠈⠁⠀⣧
⠀⠀⠀⠀⠀⠀⠀⣼⠃⠀⠀⣽⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡤⠀⠀⠀⣠⣾⣾⠟⢛⣁⣤⣠⣼⣿⣿⣿⣿⣿⣶⣄⣠⣾⣫⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠙⠷⣦⣾⣿⠟⢿⣿⣿⣿⣿⣿⣿⣿⣿⠘⣷⣱⠀⣼⣿⡯⡿⠾⠛⠛⠛⠛⠛⢻⣿⣿⠿⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣴⠋⠀⠀⣻⣿⣿⣿⣿⣿⣿⣿⣷⣿⣷⠃⢿⡟⠀⠀⠰⣦⣤⣤⣴⣶⣿⣿⣿⣤⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠇⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⡶⢿⣷⣦⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⠈⠀⠀⠀⠀⠀⠛⠉⠛⠛⠛⠻⣿⢟⣉⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡏⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠘⣼⣌⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡀⣽⣷⡶⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡘⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣯⣿⡇⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣾⣿⣷⣶⣠⣤⣠⣦⡡⣠⣼⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠇⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠑⠦⣽⡿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⣿⣿⣿⣿⠉⡆⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠿⠟⠛⠉⢿⣿⣿⣿⣿⣿⣿⣿⣿⡾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢿⣿⣟⡿⣻⣿⠟⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣠⣤⠴⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣾⣿⣿⣿⣿⣿⣿⣿⣟⡛⠁⠘⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⢀⣀⣀⣀⣀⣀⣤⢴⣾⠿⣉⣽⠞⠁⠹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢿⣿⣻⣿⣿⣿⣿⣿⣿⣿⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⡿⠒⠾⣿⣭⣌⡉⠉⠙⠳⠟⢁⣐⠛⠃⠀⢐⡶⠉⠉⠻⣿⣿⣿⣿⣯⡙⢿⣯⣉⠉⠻⣿⣿⣏⢿⣿⣿⣿⣿⣿⣬⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⣧⢐⡦⣌⠙⢮⡹⠛⢶⣤⣶⣯⣍⢰⠋⠄⠘⠁⠀⠀⠀⠈⠍⠛⠻⢿⣿⣷⣍⡻⣿⣶⣮⣙⠿⢾⣿⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⣿⣷⣤⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⣿⣿⠆⣈⠵⠶⠈⢺⡉⠙⠿⣿⣿⣿⣷⡷⠂⠀⠀⠀⠰⣾⡄⢀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⢿⣌⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣍⣽⣿⡜⣆⠳⣯⡲⣤⣀⠀⠀⠀⠀⠀⠀⠀
⣿⣿⡌⡄⠀⠀⠀⠀⠙⢶⣄⠀⠙⢿⣿⣟⣀⠀⠀⠀⠀⠈⢿⣾⡇⠀⠀⠀⣮⢙⣿⣿⣿⣿⣿⣿⣿⣻⣿⣿⣛⣿⣿⣿⣿⣿⣿⣿⣿⡿⠉⢿⡀⠀⠙⢿⣎⢿⣿⣶⣤⣀⠀⠀⠀
⣿⣿⣷⡹⠀⠀⠀⠀⠀⠀⠈⠻⢦⣄⡙⢻⣿⣾⣤⡀⠀⠀⠈⢿⣿⡀⠀⠀⠹⣾⠟⣿⣿⣿⣿⣿⣿⣿⡏⣿⣿⣿⣿⣿⣿⣿⠿⡛⠑⠀⠂⠸⡿⠝⠀⠄⢻⣧⢻⣆⠉⡹⠿⣿⡂
⣿⣿⣿⣏⠁⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⢻⣿⣿⣿⣿⣷⣄⣀⠈⣿⣷⣄⠀⠘⠙⠰⢿⣿⣿⣿⣿⣿⣿⣧⣚⣿⣿⣯⡋⠄⠰⢉⡀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣿⣧⢻⣦⠘⡇⠈⠛
⣿⣿⣿⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠈⠉⠙⠛⠛⠻⠾⣿⣿⣟⣷⠀⠀⢪⠙⢿⣿⣿⢿⣿⣿⠙⢻⣿⣿⠁⠶⠔⠈⢑⠋⠀⠀⠀⠀⠀⡀⠀⠀⢿⣿⣧⣙⠦⢻⡀⠀
⣿⣿⣿⣿⣧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⣿⣿⣿⡆⠀⠘⠷⣷⣧⣽⣾⣯⣿⡗⠸⣿⣿⠀⠠⢰⠚⠊⠀⠂⠀⠀⠀⠀⡌⠈⠒⠘⡿⡁⢹⣶⣾⡇⠀
⣿⣿⣿⣿⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠻⣿⡇⢀⠀⠀⠸⡏⡿⢷⣜⢿⡇⠀⣿⣿⡀⠆⢀⠀⠂⠀⠀⡀⠀⠀⠂⠀⠀⠀⠀⠀⠀⠀⢿⡿⠁⠀
⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⢿⣆⠀⠀⠀⠁⠀⠀⠙⣿⡇⠀⣿⣿⡇⠀⠀⠀⠀⠀⠀⠈⠂⠀⠐⠁⠀⠀⠀⠀⠀⠀⢸⠅⠀⠀
⣿⣿⣿⣿⣿⣷⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠿⣦⡀⠀⠀⠀⠀⠀⠃⣿⠀⣿⣿⡇⢀⠀⠀⠀⠀⠀⠀⠀⠘⠆⠀⠀⠀⠀⠀⠀⠀⡸⣦⠀⢀
⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠹⣷⡄⠀⣸⣿⡄⠀⡏⠀⢿⢿⡇⠀⠄⠀⠀⠘⠀⠀⠀⠀⠀⠀⢀⠀⠀⠀⡄⠀⠀⣿⣿⣿
⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⢀⠀⡀⠀⠀⠀⠀⠀⡀⠀⠀⠀⠀⠀⡀⠀⠀⠙⡽⢣⡜⠐⠹⠆⠁⠀⢺⣿⡇⠀⠀⠀⠀⠀⠀⢡⡂⠐⠀⠂⢤⡀⠈⠀⠀⠀⢀⣿⣿⣿
*/

Compilation message

rect.cpp: In constructor 'segment::segment(std::vector<int>&)':
rect.cpp:12:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |   while(sz <= v.size()) sz *= 2;
      |         ~~~^~~~~~~~~~~
rect.cpp:15:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |   for(int i=0; i<v.size(); i++) tr[i+sz] = v[i];
      |                ~^~~~~~~~~
rect.cpp: In constructor 'segment2d::segment2d(std::vector<std::vector<int> >&)':
rect.cpp:36:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |   while(sz <= v.size()) sz *= 2;
      |         ~~~^~~~~~~~~~~
rect.cpp:43:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |   for(int i=0; i<v.size(); i++) tr[i+sz] = segment(v[i]);
      |                ~^~~~~~~~~
rect.cpp: In constructor 'segment2::segment2(std::vector<int>&)':
rect.cpp:68:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |   while(sz <= v.size()) sz *= 2;
      |         ~~~^~~~~~~~~~~
rect.cpp:71:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |   for(int i=0; i<v.size(); i++) tr[i+sz] = v[i];
      |                ~^~~~~~~~~
rect.cpp: In constructor 'segment22d::segment22d(std::vector<std::vector<int> >&)':
rect.cpp:93:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   93 |   while(sz <= v.size()) sz *= 2;
      |         ~~~^~~~~~~~~~~
rect.cpp:100:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  100 |   for(int i=0; i<v.size(); i++) tr[i+sz] = segment2(v[i]);
      |                ~^~~~~~~~~
rect.cpp: In function 'long long int count_rectangles(std::vector<std::vector<int> >)':
rect.cpp:173:6: warning: unused variable 'ans' [-Wunused-variable]
  173 |  int ans = 0;
      |      ^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 392 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 392 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 4 ms 1368 KB Output is correct
23 Correct 4 ms 1368 KB Output is correct
24 Correct 4 ms 1372 KB Output is correct
25 Correct 1 ms 1116 KB Output is correct
26 Correct 2 ms 1116 KB Output is correct
27 Correct 2 ms 1116 KB Output is correct
28 Correct 2 ms 1116 KB Output is correct
29 Correct 1 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 392 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 4 ms 1368 KB Output is correct
18 Correct 4 ms 1368 KB Output is correct
19 Correct 4 ms 1372 KB Output is correct
20 Correct 1 ms 1116 KB Output is correct
21 Correct 2 ms 1116 KB Output is correct
22 Correct 2 ms 1116 KB Output is correct
23 Correct 2 ms 1116 KB Output is correct
24 Correct 1 ms 860 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 31 ms 4568 KB Output is correct
31 Correct 30 ms 4568 KB Output is correct
32 Correct 31 ms 4616 KB Output is correct
33 Correct 6 ms 3672 KB Output is correct
34 Correct 9 ms 3860 KB Output is correct
35 Correct 9 ms 3956 KB Output is correct
36 Correct 11 ms 4060 KB Output is correct
37 Correct 10 ms 3928 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 392 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 4 ms 1368 KB Output is correct
18 Correct 4 ms 1368 KB Output is correct
19 Correct 4 ms 1372 KB Output is correct
20 Correct 1 ms 1116 KB Output is correct
21 Correct 2 ms 1116 KB Output is correct
22 Correct 2 ms 1116 KB Output is correct
23 Correct 2 ms 1116 KB Output is correct
24 Correct 1 ms 860 KB Output is correct
25 Correct 31 ms 4568 KB Output is correct
26 Correct 30 ms 4568 KB Output is correct
27 Correct 31 ms 4616 KB Output is correct
28 Correct 6 ms 3672 KB Output is correct
29 Correct 9 ms 3860 KB Output is correct
30 Correct 9 ms 3956 KB Output is correct
31 Correct 11 ms 4060 KB Output is correct
32 Correct 10 ms 3928 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 52 ms 45140 KB Output is correct
39 Correct 52 ms 45140 KB Output is correct
40 Correct 53 ms 45148 KB Output is correct
41 Correct 51 ms 45140 KB Output is correct
42 Correct 656 ms 54720 KB Output is correct
43 Correct 647 ms 55492 KB Output is correct
44 Correct 666 ms 54460 KB Output is correct
45 Correct 556 ms 53792 KB Output is correct
46 Correct 66 ms 45780 KB Output is correct
47 Correct 84 ms 46288 KB Output is correct
48 Correct 124 ms 51140 KB Output is correct
49 Correct 128 ms 49868 KB Output is correct
50 Correct 62 ms 25152 KB Output is correct
51 Correct 63 ms 24956 KB Output is correct
52 Correct 163 ms 51372 KB Output is correct
53 Correct 153 ms 50864 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1116 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 1 ms 860 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 2 ms 860 KB Output is correct
6 Correct 2 ms 860 KB Output is correct
7 Correct 2 ms 860 KB Output is correct
8 Correct 1 ms 860 KB Output is correct
9 Correct 2 ms 860 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 447 ms 336100 KB Output is correct
8 Correct 933 ms 682908 KB Output is correct
9 Correct 944 ms 684732 KB Output is correct
10 Correct 943 ms 683772 KB Output is correct
11 Correct 331 ms 336456 KB Output is correct
12 Correct 623 ms 665352 KB Output is correct
13 Correct 642 ms 674576 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 392 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 4 ms 1368 KB Output is correct
18 Correct 4 ms 1368 KB Output is correct
19 Correct 4 ms 1372 KB Output is correct
20 Correct 1 ms 1116 KB Output is correct
21 Correct 2 ms 1116 KB Output is correct
22 Correct 2 ms 1116 KB Output is correct
23 Correct 2 ms 1116 KB Output is correct
24 Correct 1 ms 860 KB Output is correct
25 Correct 31 ms 4568 KB Output is correct
26 Correct 30 ms 4568 KB Output is correct
27 Correct 31 ms 4616 KB Output is correct
28 Correct 6 ms 3672 KB Output is correct
29 Correct 9 ms 3860 KB Output is correct
30 Correct 9 ms 3956 KB Output is correct
31 Correct 11 ms 4060 KB Output is correct
32 Correct 10 ms 3928 KB Output is correct
33 Correct 52 ms 45140 KB Output is correct
34 Correct 52 ms 45140 KB Output is correct
35 Correct 53 ms 45148 KB Output is correct
36 Correct 51 ms 45140 KB Output is correct
37 Correct 656 ms 54720 KB Output is correct
38 Correct 647 ms 55492 KB Output is correct
39 Correct 666 ms 54460 KB Output is correct
40 Correct 556 ms 53792 KB Output is correct
41 Correct 66 ms 45780 KB Output is correct
42 Correct 84 ms 46288 KB Output is correct
43 Correct 124 ms 51140 KB Output is correct
44 Correct 128 ms 49868 KB Output is correct
45 Correct 62 ms 25152 KB Output is correct
46 Correct 63 ms 24956 KB Output is correct
47 Correct 163 ms 51372 KB Output is correct
48 Correct 153 ms 50864 KB Output is correct
49 Correct 2 ms 1116 KB Output is correct
50 Correct 1 ms 1116 KB Output is correct
51 Correct 1 ms 860 KB Output is correct
52 Correct 0 ms 348 KB Output is correct
53 Correct 2 ms 860 KB Output is correct
54 Correct 2 ms 860 KB Output is correct
55 Correct 2 ms 860 KB Output is correct
56 Correct 1 ms 860 KB Output is correct
57 Correct 2 ms 860 KB Output is correct
58 Correct 1 ms 604 KB Output is correct
59 Correct 1 ms 860 KB Output is correct
60 Correct 0 ms 344 KB Output is correct
61 Correct 447 ms 336100 KB Output is correct
62 Correct 933 ms 682908 KB Output is correct
63 Correct 944 ms 684732 KB Output is correct
64 Correct 943 ms 683772 KB Output is correct
65 Correct 331 ms 336456 KB Output is correct
66 Correct 623 ms 665352 KB Output is correct
67 Correct 642 ms 674576 KB Output is correct
68 Correct 0 ms 348 KB Output is correct
69 Correct 0 ms 348 KB Output is correct
70 Correct 0 ms 348 KB Output is correct
71 Correct 0 ms 348 KB Output is correct
72 Correct 0 ms 348 KB Output is correct
73 Correct 768 ms 674664 KB Output is correct
74 Correct 781 ms 674496 KB Output is correct
75 Correct 766 ms 674620 KB Output is correct
76 Correct 764 ms 674640 KB Output is correct
77 Execution timed out 5091 ms 741096 KB Time limit exceeded
78 Halted 0 ms 0 KB -