Submission #430256

# Submission time Handle Problem Language Result Execution time Memory
430256 2021-06-16T12:33:34 Z schse Painting Squares (IOI20_squares) C++17
0 / 100
1 ms 328 KB
#include "squares.h"
#include <vector>
#ifndef EVAL
#include "grader.cpp"
#endif
#include <bits/stdc++.h>
#define __K 9

std::vector<int> v;
std::set<unsigned> s;
void debuijn(unsigned int curp)
{

	for (int i = 0; i < 2; ++i)
	{
		unsigned c = curp * 2 + i;
		if (s.find(c) == s.end())
		{
			s.insert(c);
			debuijn(c % (1 << (__K)));
			v.push_back(i);
		}
	}
}

std::vector<int> paint(int n)
{
	debuijn(0);
	while (v.size() > n)
		v.pop_back();
	v.push_back(__K+1);

	return v;
}

int find_location(int n, std::vector<int> c)
{
	if (c.back() == -1)
	{
		int p = n - c.size();
		while (c.back() == -1)
		{
			p++;
			c.pop_back();
		}
		return p;
	}
	for (int i = 0; i <= n - c.size(); i++)
	{
		bool b = true;
		for (int e = 0; e < c.size(); e++)
			b &= (c[e] == v[i + e]);
		if (b)
			return i;
	}
	return -1;
}

Compilation message

squares.cpp: In function 'std::vector<int> paint(int)':
squares.cpp:29:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   29 |  while (v.size() > n)
      |         ~~~~~~~~~^~~
squares.cpp: In function 'int find_location(int, std::vector<int>)':
squares.cpp:48:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |  for (int i = 0; i <= n - c.size(); i++)
      |                  ~~^~~~~~~~~~~~~~~
squares.cpp:51:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |   for (int e = 0; e < c.size(); e++)
      |                   ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 328 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 328 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 328 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 328 KB Incorrect
2 Halted 0 ms 0 KB -