Submission #653147

# Submission time Handle Problem Language Result Execution time Memory
653147 2022-10-25T19:53:22 Z aryan12 Mars (APIO22_mars) C++17
14 / 100
16 ms 2268 KB
#include "mars.h"
#include <bits/stdc++.h>
using namespace std;

string process(vector<vector<string> > a, int startR, int startC, int k, int n)
{
	string ans = "";
	if(k != 0)
	{
		for(int k = 0; k < 100; k++)
		{
			int f = 0;
			for(int i = 0; i < a.size(); i++)
			{
				for(int j = 0; j < a[i].size(); j++)
				{
					if(a[i][j][k] == '1')
					{
						f++;
					}
				}
			}
			ans += (f != 0) ? "1" : "0";
		}
		n = 2 * n + 1;
	}
	else if(k == 0)
	{
		n = 2 * n + 1;
		ans = string(100, '0');
		for(int i = 0; i < a.size(); i++)
		{
			for(int j = 0; j < a[i].size(); j++)
			{
				int idx = n * (startR + i) + startC + j;
				ans[idx] = a[i][j][0];
			}
		}
	}
	n = (n - 1) / 2;
	if(k == n - 1)
	{
		n = 2 * n + 1;
		string ans2 = ans;
		vector<bool> ok(100, false);
		int cnt = 0;
		for(int i = 0; i < ans2.size(); i++)
		{
			if(ans2[i] == '1' && !ok[i])
			{
				cnt++;
				queue<int> q;
				q.push(i);
				while(!q.empty())
				{
					int node = q.front();
					q.pop();
					if(ok[node]) continue;
					ok[node] = true;
					if(node + 1 <= 100 && ans2[node + 1] == '1' && (node + 1) % n != 0)
					{
						q.push(node + 1);
					}
					if(node - 1 >= 0 && ans2[node - 1] == '1' && node % n != 0)
					{
						q.push(node - 1);
					}
					if(node - n >= 0 && ans2[node - n] == '1')
					{
						q.push(node - n);
					}
					if(node + n <= 100 && ans2[node + n] == '1')
					{
						q.push(node + n);
					}
				}
			}
		}
		for(int i = 0; i < 100; i++)
		{
			if(i >= 10)
			{
				ans[i] = '0';
			}
			else
			{
				ans[i] = ((1 << i) & cnt) ? '1' : '0';
			}
		}
	}
	return ans;
}

Compilation message

mars.cpp: In function 'std::string process(std::vector<std::vector<std::__cxx11::basic_string<char> > >, int, int, int, int)':
mars.cpp:13:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<std::__cxx11::basic_string<char> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |    for(int i = 0; i < a.size(); i++)
      |                   ~~^~~~~~~~~~
mars.cpp:15:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     for(int j = 0; j < a[i].size(); j++)
      |                    ~~^~~~~~~~~~~~~
mars.cpp:31:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<std::__cxx11::basic_string<char> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |   for(int i = 0; i < a.size(); i++)
      |                  ~~^~~~~~~~~~
mars.cpp:33:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |    for(int j = 0; j < a[i].size(); j++)
      |                   ~~^~~~~~~~~~~~~
mars.cpp:47:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |   for(int i = 0; i < ans2.size(); i++)
      |                  ~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 9 ms 1684 KB Output is correct
2 Correct 8 ms 2128 KB Output is correct
3 Correct 8 ms 2072 KB Output is correct
4 Correct 8 ms 2060 KB Output is correct
5 Correct 8 ms 2060 KB Output is correct
6 Correct 8 ms 1956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 1684 KB Output is correct
2 Correct 8 ms 2128 KB Output is correct
3 Correct 8 ms 2072 KB Output is correct
4 Correct 8 ms 2060 KB Output is correct
5 Correct 8 ms 2060 KB Output is correct
6 Correct 8 ms 1956 KB Output is correct
7 Correct 16 ms 2100 KB Output is correct
8 Correct 16 ms 1984 KB Output is correct
9 Correct 16 ms 2076 KB Output is correct
10 Correct 16 ms 2268 KB Output is correct
11 Correct 16 ms 2104 KB Output is correct
12 Correct 16 ms 1952 KB Output is correct
13 Correct 16 ms 2128 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 1684 KB Output is correct
2 Correct 8 ms 2128 KB Output is correct
3 Correct 8 ms 2072 KB Output is correct
4 Correct 8 ms 2060 KB Output is correct
5 Correct 8 ms 2060 KB Output is correct
6 Correct 8 ms 1956 KB Output is correct
7 Correct 16 ms 2100 KB Output is correct
8 Correct 16 ms 1984 KB Output is correct
9 Correct 16 ms 2076 KB Output is correct
10 Correct 16 ms 2268 KB Output is correct
11 Correct 16 ms 2104 KB Output is correct
12 Correct 16 ms 1952 KB Output is correct
13 Correct 16 ms 2128 KB Output is correct
14 Runtime error 1 ms 460 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 1684 KB Output is correct
2 Correct 8 ms 2128 KB Output is correct
3 Correct 8 ms 2072 KB Output is correct
4 Correct 8 ms 2060 KB Output is correct
5 Correct 8 ms 2060 KB Output is correct
6 Correct 8 ms 1956 KB Output is correct
7 Correct 16 ms 2100 KB Output is correct
8 Correct 16 ms 1984 KB Output is correct
9 Correct 16 ms 2076 KB Output is correct
10 Correct 16 ms 2268 KB Output is correct
11 Correct 16 ms 2104 KB Output is correct
12 Correct 16 ms 1952 KB Output is correct
13 Correct 16 ms 2128 KB Output is correct
14 Runtime error 1 ms 460 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 1684 KB Output is correct
2 Correct 8 ms 2128 KB Output is correct
3 Correct 8 ms 2072 KB Output is correct
4 Correct 8 ms 2060 KB Output is correct
5 Correct 8 ms 2060 KB Output is correct
6 Correct 8 ms 1956 KB Output is correct
7 Correct 16 ms 2100 KB Output is correct
8 Correct 16 ms 1984 KB Output is correct
9 Correct 16 ms 2076 KB Output is correct
10 Correct 16 ms 2268 KB Output is correct
11 Correct 16 ms 2104 KB Output is correct
12 Correct 16 ms 1952 KB Output is correct
13 Correct 16 ms 2128 KB Output is correct
14 Runtime error 1 ms 460 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 1684 KB Output is correct
2 Correct 8 ms 2128 KB Output is correct
3 Correct 8 ms 2072 KB Output is correct
4 Correct 8 ms 2060 KB Output is correct
5 Correct 8 ms 2060 KB Output is correct
6 Correct 8 ms 1956 KB Output is correct
7 Correct 16 ms 2100 KB Output is correct
8 Correct 16 ms 1984 KB Output is correct
9 Correct 16 ms 2076 KB Output is correct
10 Correct 16 ms 2268 KB Output is correct
11 Correct 16 ms 2104 KB Output is correct
12 Correct 16 ms 1952 KB Output is correct
13 Correct 16 ms 2128 KB Output is correct
14 Runtime error 1 ms 460 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 1684 KB Output is correct
2 Correct 8 ms 2128 KB Output is correct
3 Correct 8 ms 2072 KB Output is correct
4 Correct 8 ms 2060 KB Output is correct
5 Correct 8 ms 2060 KB Output is correct
6 Correct 8 ms 1956 KB Output is correct
7 Correct 16 ms 2100 KB Output is correct
8 Correct 16 ms 1984 KB Output is correct
9 Correct 16 ms 2076 KB Output is correct
10 Correct 16 ms 2268 KB Output is correct
11 Correct 16 ms 2104 KB Output is correct
12 Correct 16 ms 1952 KB Output is correct
13 Correct 16 ms 2128 KB Output is correct
14 Runtime error 1 ms 460 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 1684 KB Output is correct
2 Correct 8 ms 2128 KB Output is correct
3 Correct 8 ms 2072 KB Output is correct
4 Correct 8 ms 2060 KB Output is correct
5 Correct 8 ms 2060 KB Output is correct
6 Correct 8 ms 1956 KB Output is correct
7 Correct 16 ms 2100 KB Output is correct
8 Correct 16 ms 1984 KB Output is correct
9 Correct 16 ms 2076 KB Output is correct
10 Correct 16 ms 2268 KB Output is correct
11 Correct 16 ms 2104 KB Output is correct
12 Correct 16 ms 1952 KB Output is correct
13 Correct 16 ms 2128 KB Output is correct
14 Runtime error 1 ms 460 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 1684 KB Output is correct
2 Correct 8 ms 2128 KB Output is correct
3 Correct 8 ms 2072 KB Output is correct
4 Correct 8 ms 2060 KB Output is correct
5 Correct 8 ms 2060 KB Output is correct
6 Correct 8 ms 1956 KB Output is correct
7 Correct 16 ms 2100 KB Output is correct
8 Correct 16 ms 1984 KB Output is correct
9 Correct 16 ms 2076 KB Output is correct
10 Correct 16 ms 2268 KB Output is correct
11 Correct 16 ms 2104 KB Output is correct
12 Correct 16 ms 1952 KB Output is correct
13 Correct 16 ms 2128 KB Output is correct
14 Runtime error 1 ms 460 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 1684 KB Output is correct
2 Correct 8 ms 2128 KB Output is correct
3 Correct 8 ms 2072 KB Output is correct
4 Correct 8 ms 2060 KB Output is correct
5 Correct 8 ms 2060 KB Output is correct
6 Correct 8 ms 1956 KB Output is correct
7 Correct 16 ms 2100 KB Output is correct
8 Correct 16 ms 1984 KB Output is correct
9 Correct 16 ms 2076 KB Output is correct
10 Correct 16 ms 2268 KB Output is correct
11 Correct 16 ms 2104 KB Output is correct
12 Correct 16 ms 1952 KB Output is correct
13 Correct 16 ms 2128 KB Output is correct
14 Runtime error 1 ms 460 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -