답안 #621258

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
621258 2022-08-03T15:54:41 Z cheissmart Ants and Sugar (JOI22_sugar) C++14
컴파일 오류
0 ms 0 KB
#include "rect.h"
#include <bits/stdc++.h>
#define IO_OP ios::sync_with_stdio(0), cin.tie(0)
#define F first
#define S second
#define V vector
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(v) int((v).size())
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

#ifdef CHEISSMART
void dbg() { cerr << "]" << endl; }
template<class H, class ...T> void dbg(H h, T... t) {
	cerr << to_string(h);
	if(sizeof...(t)) cerr << ", ";
	dbg(t...);
}

#define debug(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ <<"]: [", dbg(__VA_ARGS__);
#else
#define debug(...)
#endif

const int INF = 1e9 + 7;

ll count_rectangles(V<vi> a) {
	int n = SZ(a), m = SZ(a[0]);
	V<V<map<int, int>>> ver(n, V<map<int, int>>(m));
	V<V<map<int, int>>> hor(n, V<map<int, int>>(m));
	auto add_hor = [&] (int i, int j, int jj) {
		if(jj == j + 1) return;
		hor[i][j][jj] = i;
	};
	auto add_ver = [&] (int i, int j, int ii) {
		if(ii == i + 1) return;
		ver[i][j][ii] = j;
	};
	for(int i = 0; i < n; i++) {
		vi stk;
		for(int j = m - 1; j >= 0; j--) {
			while(SZ(stk) && a[i][stk.back()] < a[i][j]) {
				add_hor(i, j, stk.back());
				stk.pop_back();
			}
			if(SZ(stk))
				add_hor(i, j, stk.back());
			stk.PB(j);
		}
	}
	for(int j = 0; j < m; j++) {
		vi stk;
		for(int i = n - 1; i >= 0; i--) {
			while(SZ(stk) && a[stk.back()][j] < a[i][j]) {
				add_ver(i, j, stk.back());
				stk.pop_back();
			}
			if(SZ(stk))
				add_ver(i, j, stk.back());
			stk.PB(i);
		}
	}
	for(int i = n - 2; i >= 0; i--) {
		for(int j = 0; j < m; j++) {
			V<pi> todo;
			for(auto[jj, ii]:hor[i][j])
				if(hor[i + 1][j].count(jj))
					todo.EB(jj, hor[i + 1][j][jj]);
			for(auto[jj, ii]:todo)
				hor[i][j][jj] = ii;
		}
	}
	for(int j = m - 2; j >= 0; j--) {
		for(int i = 0; i < n; i++) {
			V<pi> todo;
			for(auto[ii, jj]:ver[i][j])
				if(ver[i][j + 1].count(ii))
					todo.EB(ii, ver[i][j + 1][ii]);
			for(auto[ii, jj]:todo)
				ver[i][j][ii] = jj;
		}
	}
	int ans = 0;
	for(int i = 1; i < n - 1; i++) {
		for(int j = 1; j < m - 1; j++) {
			for(auto[r, down]:hor[i][j - 1]) {
				for(auto[d, right]:ver[i - 1][j]) {
					if(right >= r - 1 && down >= d - 1) {
						debug(i, j, r, down, d, right);
						ans++;
					}
				}
			}
		}
	}
	return ans;

}

Compilation message

sugar.cpp:1:10: fatal error: rect.h: No such file or directory
    1 | #include "rect.h"
      |          ^~~~~~~~
compilation terminated.