Submission #775180

# Submission time Handle Problem Language Result Execution time Memory
775180 2023-07-06T08:33:59 Z CyberCow Land of the Rainbow Gold (APIO17_rainbow) C++17
Compilation error
0 ms 0 KB
#include "rainbow.h"
#include <queue>
using namespace std;
const int N = 200005;
int color[3][N];
int st[N];
int st1[N];
int st2[N];
int calooooor[55][55];
int sttttttt[55][55];
int ent = 0;

void init(int R, int C, int sr, int sc, int M, char *S) {
	if (R == 2)
		ent = 1;
	if (ent == 1)
	{
		color[sr][sc] = 1;
		for (int i = 0; i < M; i++)
		{
			if (S[i] == 'W')
			{
				sc--;
			}
			if (S[i] == 'S')
			{
				sr++;
			}
			if (S[i] == 'E')
			{
				sc++;
			}
			if (S[i] == 'N')
			{
				sr--;
			}
			color[sr][sc] = 1;
		}
		if (color[1][1] == 0 || color[2][1] == 0)
			st[1] = 1;
		for (int i = 2; i <= C; i++)
		{
			if ((color[1][i] == 0 && color[1][i - 1] == 0) || (color[2][i] == 0 && color[2][i - 1] == 0))
				st[i] = st[i - 1];
			else
			{
				if (color[1][i] == 0 || color[2][i] == 0)
					st[i] = st[i + 1];
				else
					st[i] = st[i - 1];
			}
		}
		if (color[1][1] == 0)
			st1[1] = 1;
		for (int i = 2; i <= C; i++)
		{
			if (color[1][i] == 1)
				st1[i] = st1[i - 1];
			else if (color[1][i - 1] == 0)
				st1[i] = st1[i - 1];
			else
				st1[i] = st1[i - 1] + 1;
		}
		if (color[2][1] == 0)
			st2[1] = 1;
		for (int i = 2; i <= C; i++)
		{
			if (color[2][i] == 1)
				st2[i] = st2[i - 1];
			else if (color[2][i - 1] == 0)
				st2[i] = st2[i - 1];
			else
				st2[i] = st2[i - 1] + 1;
		}
	}
	else
	{
		calooooor[sr][sc] = 1;
		for (int i = 0; i < M; i++)
		{
			if (S[i] == 'W')
			{
				sc--;
			}
			if (S[i] == 'S')
			{
				sr++;
			}
			if (S[i] == 'E')
			{
				sc++;
			}
			if (S[i] == 'N')
			{
				sr--;
			}
			calooooor[sr][sc] = 1;
		}
	}
}

int colour(int ar, int ac, int br, int bc) {
	if (ent == 1)
	{
		int qan = 0;
		if (ar == 1 && br == 1)
		{
			if (color[1][ac] == color[1][ac - 1] && color[1][ac] == 0)
			{
				qan = st1[bc] - st1[ac - 1] + 1;
			}
			else
			{
				qan = st1[bc] - st1[ac - 1];
			}
		}
		else if (ar == 2 && br == 2)
		{
			if (color[2][ac] == color[2][ac - 1] && color[2][ac] == 0)
			{
				qan = st2[bc] - st2[ac - 1] + 1;
			}
			else
			{
				qan = st2[bc] - st2[ac - 1];
			}
		}
		else
		{
			if ((color[1][ac] == 0 && color[1][ac - 1] == 0) || (color[2][ac] == 0 && color[2][ac - 1] == 0))
			{
				qan = st2[bc] - st2[ac - 1] + 1;
			}
			else
			{
				qan = st2[bc] - st2[ac - 1];
			}
		}
		return qan;
	}
	else
	{
		queue<pair<int, int>> q;
		for (int i = ar; i <= br; i++)
		{
			for (int j = ac; j <= bc; j++)
			{
				sttttttt[i][j] = 0;
			}
		}
		int qan = 0;
		for (int i = ar; i <= br; i++)
		{
			for (int j = ac; j <= bc; j++)
			{
				if (sttttttt[i][j] == 0 && color[i][j] == 0)
				{
					qan++;
					int qq = 0;
					q.push({ i, j });
					sttttttt[i][j] = 1;
					while (!q.empty())
					{
						qq++;
						int x = q.front().firsttttttt, y = q.front().second;
						q.pop();
						sttttttt[x][y] = 1;
						if (x + 1 <= br && color[x + 1][y] == 0 && sttttttt[x + 1][y] == 0)
						{
							q.push({ x + 1, y });
							sttttttt[x + 1][y] = 1;
						}
						if (x - 1 >= ar && color[x - 1][y] == 0 && sttttttt[x - 1][y] == 0)
						{
							q.push({ x - 1, y });
							sttttttt[x - 1][y] = 1;
						}
						if (y + 1 <= bc && color[x][y + 1] == 0 && sttttttt[x][y + 1] == 0)
						{
							q.push({ x, y + 1 });
							sttttttt[x][y + 1] = 1;
						}
						if (y - 1 >= ac && color[x][y - 1] == 0 && sttttttt[x][y - 1] == 0)
						{
							q.push({ x, y - 1 });
							sttttttt[x][y - 1] = 1;
						}
					}
				}
			}
		}
		for (int i = ar; i <= br; i++)
		{
			for (int j = ac; j <= bc; j++)
			{
				sttttttt[i][j] = 0;
			}
		}
		return qan;
	}
}

Compilation message

rainbow.cpp: In function 'int colour(int, int, int, int)':
rainbow.cpp:165:25: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'firsttttttt'
  165 |       int x = q.front().firsttttttt, y = q.front().second;
      |                         ^~~~~~~~~~~
rainbow.cpp:167:19: error: 'y' was not declared in this scope
  167 |       sttttttt[x][y] = 1;
      |                   ^
rainbow.cpp:170:27: error: no matching function for call to 'std::queue<std::pair<int, int> >::push(<brace-enclosed initializer list>)'
  170 |        q.push({ x + 1, y });
      |                           ^
In file included from /usr/include/c++/10/queue:64,
                 from rainbow.cpp:2:
/usr/include/c++/10/bits/stl_queue.h:265:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(const value_type&) [with _Tp = std::pair<int, int>; _Sequence = std::deque<std::pair<int, int>, std::allocator<std::pair<int, int> > >; std::queue<_Tp, _Sequence>::value_type = std::pair<int, int>]'
  265 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:265:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<int, int>&'}
  265 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_queue.h:270:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(std::queue<_Tp, _Sequence>::value_type&&) [with _Tp = std::pair<int, int>; _Sequence = std::deque<std::pair<int, int>, std::allocator<std::pair<int, int> > >; std::queue<_Tp, _Sequence>::value_type = std::pair<int, int>]'
  270 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:270:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::queue<std::pair<int, int> >::value_type&&' {aka 'std::pair<int, int>&&'}
  270 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
rainbow.cpp:175:27: error: no matching function for call to 'std::queue<std::pair<int, int> >::push(<brace-enclosed initializer list>)'
  175 |        q.push({ x - 1, y });
      |                           ^
In file included from /usr/include/c++/10/queue:64,
                 from rainbow.cpp:2:
/usr/include/c++/10/bits/stl_queue.h:265:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(const value_type&) [with _Tp = std::pair<int, int>; _Sequence = std::deque<std::pair<int, int>, std::allocator<std::pair<int, int> > >; std::queue<_Tp, _Sequence>::value_type = std::pair<int, int>]'
  265 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:265:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<int, int>&'}
  265 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_queue.h:270:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(std::queue<_Tp, _Sequence>::value_type&&) [with _Tp = std::pair<int, int>; _Sequence = std::deque<std::pair<int, int>, std::allocator<std::pair<int, int> > >; std::queue<_Tp, _Sequence>::value_type = std::pair<int, int>]'
  270 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:270:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::queue<std::pair<int, int> >::value_type&&' {aka 'std::pair<int, int>&&'}
  270 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
rainbow.cpp:180:27: error: no matching function for call to 'std::queue<std::pair<int, int> >::push(<brace-enclosed initializer list>)'
  180 |        q.push({ x, y + 1 });
      |                           ^
In file included from /usr/include/c++/10/queue:64,
                 from rainbow.cpp:2:
/usr/include/c++/10/bits/stl_queue.h:265:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(const value_type&) [with _Tp = std::pair<int, int>; _Sequence = std::deque<std::pair<int, int>, std::allocator<std::pair<int, int> > >; std::queue<_Tp, _Sequence>::value_type = std::pair<int, int>]'
  265 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:265:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<int, int>&'}
  265 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_queue.h:270:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(std::queue<_Tp, _Sequence>::value_type&&) [with _Tp = std::pair<int, int>; _Sequence = std::deque<std::pair<int, int>, std::allocator<std::pair<int, int> > >; std::queue<_Tp, _Sequence>::value_type = std::pair<int, int>]'
  270 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:270:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::queue<std::pair<int, int> >::value_type&&' {aka 'std::pair<int, int>&&'}
  270 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
rainbow.cpp:185:27: error: no matching function for call to 'std::queue<std::pair<int, int> >::push(<brace-enclosed initializer list>)'
  185 |        q.push({ x, y - 1 });
      |                           ^
In file included from /usr/include/c++/10/queue:64,
                 from rainbow.cpp:2:
/usr/include/c++/10/bits/stl_queue.h:265:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(const value_type&) [with _Tp = std::pair<int, int>; _Sequence = std::deque<std::pair<int, int>, std::allocator<std::pair<int, int> > >; std::queue<_Tp, _Sequence>::value_type = std::pair<int, int>]'
  265 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:265:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<int, int>&'}
  265 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_queue.h:270:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(std::queue<_Tp, _Sequence>::value_type&&) [with _Tp = std::pair<int, int>; _Sequence = std::deque<std::pair<int, int>, std::allocator<std::pair<int, int> > >; std::queue<_Tp, _Sequence>::value_type = std::pair<int, int>]'
  270 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:270:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::queue<std::pair<int, int> >::value_type&&' {aka 'std::pair<int, int>&&'}
  270 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~