Submission #1049341

# Submission time Handle Problem Language Result Execution time Memory
1049341 2024-08-08T16:44:18 Z Marco_Escandon Mars (APIO22_mars) C++17
6 / 100
8 ms 2920 KB
//#include "mars.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string merge(vector <vector<string>> a, int x, int y, int k, int n)
{
	if(x!= 2*(n-k-1) && y!= 2*(n-k-1)) return a[0][0];
	vector<vector<char>> cad(n*2+1,vector<char>(n*2+1,'0'));
	int pl=(k==0);
	for(int i=x; i<=x+1+pl; i++)
	{
		for(int j=y; j<=y+1+pl; j++)
		{
			cad[i][j]=max(cad[i][j],a[i-x][j-y][0]);
		}
	}
	string s;
	for(int i=0; i<cad.size(); i++)
	{
		for(int j=0; j<cad[0].size(); j++)
		{
			s+=cad[i][j];
		}
	}
	while(s.size()<100) s+='0';
	if(!pl)
	{
		for(int j=0; j<3; j++)
		for(int i=0; i<100; i++)
		{
			s[i]=max(s[i],a[2][j][i]);
			s[i]=max(s[i],a[j][2][i]);
		}
	}
	return s;
}
vector<vector<char>> cad;
ll dx[]={1, 0,-1, 0};
ll dy[]={0, 1, 0,-1};
void dfs(ll i,ll j)
{
	if(cad[i][j]=='0') return;
	cad[i][j]='0';
	for(int k=0; k<4; k++)
	{
		dfs(dx[k]+i,dy[k]+j);
	}
}
std::string process(std::vector <std::vector<std::string>> a, int i, int j, int k, int n)
{
	if(k==n-1) 
	{
		string temp=merge(a,i,j,k,n);
		cad.assign(n*2+4,vector<char>(n*2+4,'0'));
		for(int i=0; i<(2*n+1); i++)
		{
			for(int j=0; j<(2*n+1); j++)
			{
				cad[i+1][j+1]=temp[i*(2*n+1)+j];
			}
		}
		ll cont=0;
		for(int i=1; i<cad.size()-1; i++)
		{
			for(int j=1; j<cad[0].size()-1; j++)
			{
				if(cad[i][j]!='0')
				{
					cont++;
					dfs(i,j);
				}
			}
		}
		string sol="";
		while(cont>0)
		{
			sol+=(cont%2+'0');
			cont/=2;
		}
		while(sol.size()<100) sol+='0';
		return sol;
	}
	else return merge(a,i,j,k,n);
}

Compilation message

mars.cpp: In function 'std::string merge(std::vector<std::vector<std::__cxx11::basic_string<char> > >, int, int, int, int)':
mars.cpp:18:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |  for(int i=0; i<cad.size(); i++)
      |               ~^~~~~~~~~~~
mars.cpp:20:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |   for(int j=0; j<cad[0].size(); j++)
      |                ~^~~~~~~~~~~~~~
mars.cpp: In function 'std::string process(std::vector<std::vector<std::__cxx11::basic_string<char> > >, int, int, int, int)':
mars.cpp:63:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |   for(int i=1; i<cad.size()-1; i++)
      |                ~^~~~~~~~~~~~~
mars.cpp:65:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |    for(int j=1; j<cad[0].size()-1; j++)
      |                 ~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2844 KB Output is correct
2 Correct 8 ms 2744 KB Output is correct
3 Correct 8 ms 2920 KB Output is correct
4 Correct 3 ms 2748 KB Output is correct
5 Correct 7 ms 2920 KB Output is correct
6 Correct 6 ms 2832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2844 KB Output is correct
2 Correct 8 ms 2744 KB Output is correct
3 Correct 8 ms 2920 KB Output is correct
4 Correct 3 ms 2748 KB Output is correct
5 Correct 7 ms 2920 KB Output is correct
6 Correct 6 ms 2832 KB Output is correct
7 Correct 8 ms 2828 KB Output is correct
8 Correct 8 ms 2836 KB Output is correct
9 Incorrect 2 ms 332 KB Incorrect
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2844 KB Output is correct
2 Correct 8 ms 2744 KB Output is correct
3 Correct 8 ms 2920 KB Output is correct
4 Correct 3 ms 2748 KB Output is correct
5 Correct 7 ms 2920 KB Output is correct
6 Correct 6 ms 2832 KB Output is correct
7 Correct 8 ms 2828 KB Output is correct
8 Correct 8 ms 2836 KB Output is correct
9 Incorrect 2 ms 332 KB Incorrect
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2844 KB Output is correct
2 Correct 8 ms 2744 KB Output is correct
3 Correct 8 ms 2920 KB Output is correct
4 Correct 3 ms 2748 KB Output is correct
5 Correct 7 ms 2920 KB Output is correct
6 Correct 6 ms 2832 KB Output is correct
7 Correct 8 ms 2828 KB Output is correct
8 Correct 8 ms 2836 KB Output is correct
9 Incorrect 2 ms 332 KB Incorrect
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2844 KB Output is correct
2 Correct 8 ms 2744 KB Output is correct
3 Correct 8 ms 2920 KB Output is correct
4 Correct 3 ms 2748 KB Output is correct
5 Correct 7 ms 2920 KB Output is correct
6 Correct 6 ms 2832 KB Output is correct
7 Correct 8 ms 2828 KB Output is correct
8 Correct 8 ms 2836 KB Output is correct
9 Incorrect 2 ms 332 KB Incorrect
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2844 KB Output is correct
2 Correct 8 ms 2744 KB Output is correct
3 Correct 8 ms 2920 KB Output is correct
4 Correct 3 ms 2748 KB Output is correct
5 Correct 7 ms 2920 KB Output is correct
6 Correct 6 ms 2832 KB Output is correct
7 Correct 8 ms 2828 KB Output is correct
8 Correct 8 ms 2836 KB Output is correct
9 Incorrect 2 ms 332 KB Incorrect
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2844 KB Output is correct
2 Correct 8 ms 2744 KB Output is correct
3 Correct 8 ms 2920 KB Output is correct
4 Correct 3 ms 2748 KB Output is correct
5 Correct 7 ms 2920 KB Output is correct
6 Correct 6 ms 2832 KB Output is correct
7 Correct 8 ms 2828 KB Output is correct
8 Correct 8 ms 2836 KB Output is correct
9 Incorrect 2 ms 332 KB Incorrect
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2844 KB Output is correct
2 Correct 8 ms 2744 KB Output is correct
3 Correct 8 ms 2920 KB Output is correct
4 Correct 3 ms 2748 KB Output is correct
5 Correct 7 ms 2920 KB Output is correct
6 Correct 6 ms 2832 KB Output is correct
7 Correct 8 ms 2828 KB Output is correct
8 Correct 8 ms 2836 KB Output is correct
9 Incorrect 2 ms 332 KB Incorrect
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2844 KB Output is correct
2 Correct 8 ms 2744 KB Output is correct
3 Correct 8 ms 2920 KB Output is correct
4 Correct 3 ms 2748 KB Output is correct
5 Correct 7 ms 2920 KB Output is correct
6 Correct 6 ms 2832 KB Output is correct
7 Correct 8 ms 2828 KB Output is correct
8 Correct 8 ms 2836 KB Output is correct
9 Incorrect 2 ms 332 KB Incorrect
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2844 KB Output is correct
2 Correct 8 ms 2744 KB Output is correct
3 Correct 8 ms 2920 KB Output is correct
4 Correct 3 ms 2748 KB Output is correct
5 Correct 7 ms 2920 KB Output is correct
6 Correct 6 ms 2832 KB Output is correct
7 Correct 8 ms 2828 KB Output is correct
8 Correct 8 ms 2836 KB Output is correct
9 Incorrect 2 ms 332 KB Incorrect
10 Halted 0 ms 0 KB -