Submission #519053

# Submission time Handle Problem Language Result Execution time Memory
519053 2022-01-25T13:28:41 Z thegrimbee Square or Rectangle? (NOI19_squarerect) C++14
0 / 100
0 ms 204 KB
#include "squarerect.h"
#include <bits/stdc++.h>
using namespace std;

bool am_i_square(int N, int Q) {
	bool visited[100][100];
	int i, j, tempi, tempj;
	bool temp;
	for (i = 1; i <100; i += 20){
		for (j = 1; j < 100; j += 20){
			if (inside_shape(i, j)){tempi = i; tempj = j;j=101;i=101;}
		}
	}
	if (i == 101 && j == 101)return false;
	i = tempi;
	j = tempj;
	int lo, hi, mid, len, len2;
	lo  = j - 19;
	hi = j;
	mid = (lo + hi)/ 2;
	if (lo > 0){
		while (lo <= mid && !(tempi == mid)){
			tempi = mid;
			temp = inside_shape(i, mid);
			visited[i-1][mid-1] = temp;
			if (temp)hi = mid;
			else lo = mid;
			mid = (lo + hi)/2;
			
		}
	}
	else{
		mid = j;
	}
	len = j - mid + (int)visited[i-1][mid-1];
	lo = j + 19 - len;
	hi = 101;
	mid = (lo + hi)/2;
	while (lo <= mid&& !(tempi == mid)){
			tempi = mid;
			temp = inside_shape(i, mid);
			visited[i-1][mid-1] = temp;
			if (!temp)hi = mid;
			else {lo = mid;if(mid - j + len > 101 - max(1, i - 20))return false;}
			mid = (lo + hi)/2;
		}
	len += mid - j + (int)visited[i-1][mid-1] - 1;
	if (len < 20)return false;
	lo = max(1, i - 19);
	hi = i;
	mid = (lo + hi) / 2;
	temp = false;
	while (lo <= mid&& !(tempi == mid)){
		tempi = mid;
		temp = inside_shape(mid, j);
		visited[mid-1][j-1] = temp;
		if (temp)hi = mid;
		else {lo = mid;if(101 - mid < len)return false;}
		mid = (lo + hi)/2;
	}
	len2 = i - mid + (int)visited[mid-1][j-1];
	temp = inside_shape(i + len-len2, j);
	if (!temp) return false;
	if (((i + len - len2 == 100) && temp) || (temp && !inside_shape(i + len-len2 + 1, j)))return true;
	return false;
}

Compilation message

squarerect.cpp: In function 'bool am_i_square(int, int)':
squarerect.cpp:35:10: warning: 'tempj' may be used uninitialized in this function [-Wmaybe-uninitialized]
   35 |  len = j - mid + (int)visited[i-1][mid-1];
      |        ~~^~~~~
squarerect.cpp:62:24: warning: 'tempi' may be used uninitialized in this function [-Wmaybe-uninitialized]
   62 |  temp = inside_shape(i + len-len2, j);
      |                      ~~^~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Wrong Answer.
2 Halted 0 ms 0 KB -