Submission #143968

# Submission time Handle Problem Language Result Execution time Memory
143968 2019-08-15T13:56:18 Z tincamatei Rectangles (IOI19_rect) C++14
0 / 100
3 ms 380 KB
#include "rect.h"

using namespace std;

bool goodRect(int i, int j, int exp) {
	return j - i - 1 > 0 && exp >= j - i - 1;
}

long long subtask5(const vector<vector<int> > &matr) {
	int N = matr.size(), M = matr[0].size();
	int exp = 0;
	int top = 0;
	long long rez = 0LL;
	vector<int> stiva(M);
	
	for(int c = 0; c < M; ++c) {
		bool eq = false;

		while(top > 0 && matr[1][c] >= matr[1][stiva[top - 1]]) {
			rez = rez + goodRect(stiva[top - 1], c, exp);
			if(matr[1][c] == matr[1][stiva[top - 1]])
				eq = true;
			--top;
		}

		if(!eq && top > 0)
			rez = rez + goodRect(stiva[top - 1], c, exp);
		stiva[top++] = c;

		if(matr[0][c] > matr[1][c] && matr[2][c] > matr[1][c])
			++exp;
		else
			exp = 0;
	}
	return rez;
}

long long count_rectangles(std::vector<std::vector<int> > a) {
	int N;
	N = a.size();

	if(N == 3)
		return subtask5(a);
	return 1;
}

Compilation message

rect.cpp: In function 'long long int subtask5(const std::vector<std::vector<int> >&)':
rect.cpp:10:6: warning: unused variable 'N' [-Wunused-variable]
  int N = matr.size(), M = matr[0].size();
      ^
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 380 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 252 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Incorrect 2 ms 256 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -