Submission #152085

# Submission time Handle Problem Language Result Execution time Memory
152085 2019-09-06T10:33:43 Z oolimry Rectangles (IOI19_rect) C++14
Compilation error
0 ms 0 KB
long long count_rectangles(std::vector<std::vector<int> > b) {
	int rows = b.size();
	int cols = b[0].size();
	for(int r = 0;r < rows;r++){
		for(int c = 0;c < cols;c++){
			a[r][c] = b[r][c];
		}
	}
	//Segment hori[rows];
	//Segment vert[cols];
 
	set<long long> answers;
	for(int c = 0;c < cols;c++){
		//vert[c].create(rows);
	}
	for(int r = 0;r < rows;r++){
		//hori[r].create(cols);
 
	}
	for(int r = 0;r < rows;r++){
		for(int c = 0;c < cols;c++){
			//hori[r].update(c,a[r][c]);
			//vert[c].update(r,a[r][c]);
			update(r,c,a[r][c]);
			update(rows+c,r,a[r][c]);
		}
	}
	typedef pair<int,int> ii;
	typedef pair<int,ii> iii;
	
	vector<iii> points;
	for(int r = 0;r < rows;r++){
		for(int c = 0;c < cols;c++){
			points.push_back(iii(a[r][c],ii(r,c)));
		}
	}
	
	sort(points.begin(),points.end());
	stack<ii> arr;
	for(int p = 0;p < points.size();p++){
		int rr = points[p].second.first;
		int cc = points[p].second.second;
		//cout << rr << " " << cc << " " << a[rr][cc] << "\n";
		arr.push(ii(rr,cc));
		if(p == points.size()-1 || points[p].first != points[p+1].first){
			while(!arr.empty()){
				int r = arr.top().first;
				int c = arr.top().second;
				arr.pop();
				if(r == 0 || r == rows - 1 || c == 0 || c == cols-1) continue;
				
				//if(hhh[r].query(c) != 0) continue;
				
				int lr = r, hr = r, lc = c, hc = c; //exclusive
				
				while(lr > 0){
					if(a[lr][c] > a[r][c]) break;
					lr--;
				}
				
				while(hr < rows-1){
					if(a[hr][c] > a[r][c]) break;
					hr++;
				}
				
				while(lc > 0){
					if(a[r][lc] > a[r][c]) break;
					lc--;
				}
				
				while(hc < cols-1){
					if(a[r][hc] > a[r][c]) break;
					hc++;
				}
				
				bool can = true;
				for(int sr = lr+1;sr < hr;sr++){
					int value = query(sr,lc+1,hc);
					if(value >= a[sr][lc] || value >= a[sr][hc]){
						can = false;
						break;
					}
				}
				for(int sc = lc+1;sc < hc;sc++){
					int value = query(sc+rows,lr+1,hr);
					if(value >= a[lr][sc] || value >= a[hr][sc]){
						can = false;
						break;
					}
				}
				
				if(can){
					
					long long vvv = lr * 1000000000ll;
					vvv += hr * 1000000ll;
					vvv += lc * 1000ll;
					vvv += hc;
					answers.insert(vvv);
				}
				
				//cout << r << " " << c << " " << lr << " " << hr << " " << lc << " " << hc << "\n";
			}
			
		}
	}
	return answers.size();
}

Compilation message

rect.cpp:1:33: error: 'vector' is not a member of 'std'
 long long count_rectangles(std::vector<std::vector<int> > b) {
                                 ^~~~~~
rect.cpp:1:45: error: 'vector' is not a member of 'std'
 long long count_rectangles(std::vector<std::vector<int> > b) {
                                             ^~~~~~
rect.cpp:1:52: error: expected primary-expression before 'int'
 long long count_rectangles(std::vector<std::vector<int> > b) {
                                                    ^~~