# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1035645 |
2024-07-26T12:52:25 Z |
amine_aroua |
Mars (APIO22_mars) |
C++17 |
|
1 ms |
336 KB |
#include "mars.h"
#include<bits/stdc++.h>
using namespace std;
int xx[4] = {1 , -1 , 0 , 0};
int yy[4] = {0 , 0 , -1 , 1};
void dfs(int x , int y, int &pass , vector<vector<bool>> &vis , string &ret , int &n)
{
if(vis[x][y])
{
return ;
}
pass++;
vis[x][y] = 1;
for(int k = 0 ; k < 4 ; k++)
{
int nx = x + xx[k] , ny = y + yy[k];
if(nx >= 0 && ny >= 0 && nx < n && ny < n && ret[nx * n + ny] == '1')
{
dfs(nx , ny ,pass ,vis , ret , n);
}
}
}
std::string process(std::vector <std::vector<std::string>> a, int i, int j, int k, int n)
{
string ret(100 , '0');
int N = 2*n + 1;
for(int x = i ; x <= i + 2 ; x++)
{
for(int y = j ; y <= j + 2 ; y++)
{
if(k == 0)
{
swap(a[x - i][y - j][0] , a[x - i][y - j][N * x + y]);
}
for(int z = 0 ; z < 100 ; z++)
{
ret[z]|=a[x - i][y - j][z];
}
}
}
if(k == n - 1)
{
vector<vector<bool>> vis(2 * n +1 , vector<bool>(2 * n + 1));
int cnt = 0;
int mx = 0;
for(int x = 0 ;x < N ; x++)
{
for(int y = 0 ; y < N ; y++)
{
if(!vis[x][y] && ret[N * x + y] == '1')
{
cnt = 0;
dfs(x , y , cnt , vis, ret , N);
mx = max(mx , cnt);
}
}
}
vis = vector<vector<bool>> (2*n + 1 , vector<bool>(2 * n +1));
cnt = 0;
int ans = 0;
for(int x = 0 ;x < N ; x++)
{
for(int y = 0 ; y < N ; y++)
{
if(!vis[x][y] && ret[N * x + y] == '1')
{
cnt = 0;
dfs(x , y , cnt , vis, ret , N);
if(mx == cnt)
{
ans++;
}
}
}
}
string s(100 , '0');
for(int x = 0 ; x < 20; x++)
{
if((1<<x) & ans)
{
s[x] = '1';
}
}
return s;
}
return ret;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |