//#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++)
{
if(x== 2*(n-k-1))
s[i]=max(s[i],a[2][j][i]);
if(y== 2*(n-k-1))
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:65:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
65 | for(int i=1; i<cad.size()-1; i++)
| ~^~~~~~~~~~~~~
mars.cpp:67:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
67 | for(int j=1; j<cad[0].size()-1; j++)
| ~^~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
3504 KB |
Output is correct |
2 |
Correct |
4 ms |
2748 KB |
Output is correct |
3 |
Correct |
4 ms |
2836 KB |
Output is correct |
4 |
Correct |
3 ms |
2664 KB |
Output is correct |
5 |
Correct |
8 ms |
3088 KB |
Output is correct |
6 |
Correct |
6 ms |
2696 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
3504 KB |
Output is correct |
2 |
Correct |
4 ms |
2748 KB |
Output is correct |
3 |
Correct |
4 ms |
2836 KB |
Output is correct |
4 |
Correct |
3 ms |
2664 KB |
Output is correct |
5 |
Correct |
8 ms |
3088 KB |
Output is correct |
6 |
Correct |
6 ms |
2696 KB |
Output is correct |
7 |
Correct |
8 ms |
2748 KB |
Output is correct |
8 |
Correct |
8 ms |
2744 KB |
Output is correct |
9 |
Correct |
12 ms |
2740 KB |
Output is correct |
10 |
Correct |
13 ms |
2996 KB |
Output is correct |
11 |
Correct |
11 ms |
2932 KB |
Output is correct |
12 |
Correct |
8 ms |
2944 KB |
Output is correct |
13 |
Correct |
8 ms |
2764 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
3504 KB |
Output is correct |
2 |
Correct |
4 ms |
2748 KB |
Output is correct |
3 |
Correct |
4 ms |
2836 KB |
Output is correct |
4 |
Correct |
3 ms |
2664 KB |
Output is correct |
5 |
Correct |
8 ms |
3088 KB |
Output is correct |
6 |
Correct |
6 ms |
2696 KB |
Output is correct |
7 |
Correct |
8 ms |
2748 KB |
Output is correct |
8 |
Correct |
8 ms |
2744 KB |
Output is correct |
9 |
Correct |
12 ms |
2740 KB |
Output is correct |
10 |
Correct |
13 ms |
2996 KB |
Output is correct |
11 |
Correct |
11 ms |
2932 KB |
Output is correct |
12 |
Correct |
8 ms |
2944 KB |
Output is correct |
13 |
Correct |
8 ms |
2764 KB |
Output is correct |
14 |
Incorrect |
2 ms |
332 KB |
invalid len |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
3504 KB |
Output is correct |
2 |
Correct |
4 ms |
2748 KB |
Output is correct |
3 |
Correct |
4 ms |
2836 KB |
Output is correct |
4 |
Correct |
3 ms |
2664 KB |
Output is correct |
5 |
Correct |
8 ms |
3088 KB |
Output is correct |
6 |
Correct |
6 ms |
2696 KB |
Output is correct |
7 |
Correct |
8 ms |
2748 KB |
Output is correct |
8 |
Correct |
8 ms |
2744 KB |
Output is correct |
9 |
Correct |
12 ms |
2740 KB |
Output is correct |
10 |
Correct |
13 ms |
2996 KB |
Output is correct |
11 |
Correct |
11 ms |
2932 KB |
Output is correct |
12 |
Correct |
8 ms |
2944 KB |
Output is correct |
13 |
Correct |
8 ms |
2764 KB |
Output is correct |
14 |
Incorrect |
2 ms |
332 KB |
invalid len |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
3504 KB |
Output is correct |
2 |
Correct |
4 ms |
2748 KB |
Output is correct |
3 |
Correct |
4 ms |
2836 KB |
Output is correct |
4 |
Correct |
3 ms |
2664 KB |
Output is correct |
5 |
Correct |
8 ms |
3088 KB |
Output is correct |
6 |
Correct |
6 ms |
2696 KB |
Output is correct |
7 |
Correct |
8 ms |
2748 KB |
Output is correct |
8 |
Correct |
8 ms |
2744 KB |
Output is correct |
9 |
Correct |
12 ms |
2740 KB |
Output is correct |
10 |
Correct |
13 ms |
2996 KB |
Output is correct |
11 |
Correct |
11 ms |
2932 KB |
Output is correct |
12 |
Correct |
8 ms |
2944 KB |
Output is correct |
13 |
Correct |
8 ms |
2764 KB |
Output is correct |
14 |
Incorrect |
2 ms |
332 KB |
invalid len |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
3504 KB |
Output is correct |
2 |
Correct |
4 ms |
2748 KB |
Output is correct |
3 |
Correct |
4 ms |
2836 KB |
Output is correct |
4 |
Correct |
3 ms |
2664 KB |
Output is correct |
5 |
Correct |
8 ms |
3088 KB |
Output is correct |
6 |
Correct |
6 ms |
2696 KB |
Output is correct |
7 |
Correct |
8 ms |
2748 KB |
Output is correct |
8 |
Correct |
8 ms |
2744 KB |
Output is correct |
9 |
Correct |
12 ms |
2740 KB |
Output is correct |
10 |
Correct |
13 ms |
2996 KB |
Output is correct |
11 |
Correct |
11 ms |
2932 KB |
Output is correct |
12 |
Correct |
8 ms |
2944 KB |
Output is correct |
13 |
Correct |
8 ms |
2764 KB |
Output is correct |
14 |
Incorrect |
2 ms |
332 KB |
invalid len |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
3504 KB |
Output is correct |
2 |
Correct |
4 ms |
2748 KB |
Output is correct |
3 |
Correct |
4 ms |
2836 KB |
Output is correct |
4 |
Correct |
3 ms |
2664 KB |
Output is correct |
5 |
Correct |
8 ms |
3088 KB |
Output is correct |
6 |
Correct |
6 ms |
2696 KB |
Output is correct |
7 |
Correct |
8 ms |
2748 KB |
Output is correct |
8 |
Correct |
8 ms |
2744 KB |
Output is correct |
9 |
Correct |
12 ms |
2740 KB |
Output is correct |
10 |
Correct |
13 ms |
2996 KB |
Output is correct |
11 |
Correct |
11 ms |
2932 KB |
Output is correct |
12 |
Correct |
8 ms |
2944 KB |
Output is correct |
13 |
Correct |
8 ms |
2764 KB |
Output is correct |
14 |
Incorrect |
2 ms |
332 KB |
invalid len |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
3504 KB |
Output is correct |
2 |
Correct |
4 ms |
2748 KB |
Output is correct |
3 |
Correct |
4 ms |
2836 KB |
Output is correct |
4 |
Correct |
3 ms |
2664 KB |
Output is correct |
5 |
Correct |
8 ms |
3088 KB |
Output is correct |
6 |
Correct |
6 ms |
2696 KB |
Output is correct |
7 |
Correct |
8 ms |
2748 KB |
Output is correct |
8 |
Correct |
8 ms |
2744 KB |
Output is correct |
9 |
Correct |
12 ms |
2740 KB |
Output is correct |
10 |
Correct |
13 ms |
2996 KB |
Output is correct |
11 |
Correct |
11 ms |
2932 KB |
Output is correct |
12 |
Correct |
8 ms |
2944 KB |
Output is correct |
13 |
Correct |
8 ms |
2764 KB |
Output is correct |
14 |
Incorrect |
2 ms |
332 KB |
invalid len |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
3504 KB |
Output is correct |
2 |
Correct |
4 ms |
2748 KB |
Output is correct |
3 |
Correct |
4 ms |
2836 KB |
Output is correct |
4 |
Correct |
3 ms |
2664 KB |
Output is correct |
5 |
Correct |
8 ms |
3088 KB |
Output is correct |
6 |
Correct |
6 ms |
2696 KB |
Output is correct |
7 |
Correct |
8 ms |
2748 KB |
Output is correct |
8 |
Correct |
8 ms |
2744 KB |
Output is correct |
9 |
Correct |
12 ms |
2740 KB |
Output is correct |
10 |
Correct |
13 ms |
2996 KB |
Output is correct |
11 |
Correct |
11 ms |
2932 KB |
Output is correct |
12 |
Correct |
8 ms |
2944 KB |
Output is correct |
13 |
Correct |
8 ms |
2764 KB |
Output is correct |
14 |
Incorrect |
2 ms |
332 KB |
invalid len |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
3504 KB |
Output is correct |
2 |
Correct |
4 ms |
2748 KB |
Output is correct |
3 |
Correct |
4 ms |
2836 KB |
Output is correct |
4 |
Correct |
3 ms |
2664 KB |
Output is correct |
5 |
Correct |
8 ms |
3088 KB |
Output is correct |
6 |
Correct |
6 ms |
2696 KB |
Output is correct |
7 |
Correct |
8 ms |
2748 KB |
Output is correct |
8 |
Correct |
8 ms |
2744 KB |
Output is correct |
9 |
Correct |
12 ms |
2740 KB |
Output is correct |
10 |
Correct |
13 ms |
2996 KB |
Output is correct |
11 |
Correct |
11 ms |
2932 KB |
Output is correct |
12 |
Correct |
8 ms |
2944 KB |
Output is correct |
13 |
Correct |
8 ms |
2764 KB |
Output is correct |
14 |
Incorrect |
2 ms |
332 KB |
invalid len |
15 |
Halted |
0 ms |
0 KB |
- |