Submission #1049327

# Submission time Handle Problem Language Result Execution time Memory
1049327 2024-08-08T16:32:54 Z Marco_Escandon Mars (APIO22_mars) C++17
6 / 100
8 ms 3680 KB
#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[x+2][y+j][i]);
			s[i]=max(s[i],a[x+j][y+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:17:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |  for(int i=0; i<cad.size(); i++)
      |               ~^~~~~~~~~~~
mars.cpp:19:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |   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:62:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |   for(int i=1; i<cad.size()-1; i++)
      |                ~^~~~~~~~~~~~~
mars.cpp:64:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |    for(int j=1; j<cad[0].size()-1; j++)
      |                 ~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2992 KB Output is correct
2 Correct 8 ms 2740 KB Output is correct
3 Correct 8 ms 2748 KB Output is correct
4 Correct 6 ms 2828 KB Output is correct
5 Correct 8 ms 2744 KB Output is correct
6 Correct 3 ms 3680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2992 KB Output is correct
2 Correct 8 ms 2740 KB Output is correct
3 Correct 8 ms 2748 KB Output is correct
4 Correct 6 ms 2828 KB Output is correct
5 Correct 8 ms 2744 KB Output is correct
6 Correct 3 ms 3680 KB Output is correct
7 Runtime error 2 ms 588 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2992 KB Output is correct
2 Correct 8 ms 2740 KB Output is correct
3 Correct 8 ms 2748 KB Output is correct
4 Correct 6 ms 2828 KB Output is correct
5 Correct 8 ms 2744 KB Output is correct
6 Correct 3 ms 3680 KB Output is correct
7 Runtime error 2 ms 588 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2992 KB Output is correct
2 Correct 8 ms 2740 KB Output is correct
3 Correct 8 ms 2748 KB Output is correct
4 Correct 6 ms 2828 KB Output is correct
5 Correct 8 ms 2744 KB Output is correct
6 Correct 3 ms 3680 KB Output is correct
7 Runtime error 2 ms 588 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2992 KB Output is correct
2 Correct 8 ms 2740 KB Output is correct
3 Correct 8 ms 2748 KB Output is correct
4 Correct 6 ms 2828 KB Output is correct
5 Correct 8 ms 2744 KB Output is correct
6 Correct 3 ms 3680 KB Output is correct
7 Runtime error 2 ms 588 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2992 KB Output is correct
2 Correct 8 ms 2740 KB Output is correct
3 Correct 8 ms 2748 KB Output is correct
4 Correct 6 ms 2828 KB Output is correct
5 Correct 8 ms 2744 KB Output is correct
6 Correct 3 ms 3680 KB Output is correct
7 Runtime error 2 ms 588 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2992 KB Output is correct
2 Correct 8 ms 2740 KB Output is correct
3 Correct 8 ms 2748 KB Output is correct
4 Correct 6 ms 2828 KB Output is correct
5 Correct 8 ms 2744 KB Output is correct
6 Correct 3 ms 3680 KB Output is correct
7 Runtime error 2 ms 588 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2992 KB Output is correct
2 Correct 8 ms 2740 KB Output is correct
3 Correct 8 ms 2748 KB Output is correct
4 Correct 6 ms 2828 KB Output is correct
5 Correct 8 ms 2744 KB Output is correct
6 Correct 3 ms 3680 KB Output is correct
7 Runtime error 2 ms 588 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2992 KB Output is correct
2 Correct 8 ms 2740 KB Output is correct
3 Correct 8 ms 2748 KB Output is correct
4 Correct 6 ms 2828 KB Output is correct
5 Correct 8 ms 2744 KB Output is correct
6 Correct 3 ms 3680 KB Output is correct
7 Runtime error 2 ms 588 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2992 KB Output is correct
2 Correct 8 ms 2740 KB Output is correct
3 Correct 8 ms 2748 KB Output is correct
4 Correct 6 ms 2828 KB Output is correct
5 Correct 8 ms 2744 KB Output is correct
6 Correct 3 ms 3680 KB Output is correct
7 Runtime error 2 ms 588 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -