This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "mars.h"
#define F first
#define S second
#define OK cout << "------OK---------" << endl;
#define deb(x) cout << #x << " = " << x << endl;
#define ll long long ;
using namespace std ;
const int N = 500 + 7;
const int INF = 1e9 + 7 ;
const int dx[4] = {0 , 1 , 0 , -1} , dy[4] = {1 , 0 , -1 , 0} ;
int used[N][N], n ;
int pos(int I , int J ){
return I * (2 * n + 1) + J ;
}
void dfs(int i ,int j , string res){
used[i][j] = 1;
for(int k = 0 ; k < 4; k++){
int I = i + dx[k] , J = j + dy[k] ;
if(I >= 0 and I <= 2 * n and J >= 0 and J <= 2 * n and used[I][J] == 0 and res[pos(I , J)] == '1')
dfs(I , J , res );
}
}
string calc(string res){
int cnt = 0 ;
for(int i = 0 ; i < 2 * n + 1 ; i++){
for(int j = 0 ; j < 2 * n + 1 ; j++){
used[i][j] = 0 ;
}
}
for(int i = 0 ; i< 2 * n + 1 ; i++){
for(int j = 0 ; j< 2 * n + 1; j++){
if(used[i][j] == 0 and res[pos(i , j)] == '1'){
cnt++;
dfs(i , j , res) ;
}
}
}
string bin ;
while(cnt){
bin += char(cnt % 2 + '0') ;
cnt /= 2;
}
while(bin.size() < 100)
bin += '0' ;
return bin ;
}
string process(vector <vector<string>> a, int I, int J, int k, int mn){
n = mn ;
string res = string(100 , '0') ;
if(k == 0){
for(int i = 0 ; i < 3; i++){
for(int j = 0 ; j< 3 ; j++){
int I1 = I + i , J1 = J + j ;
int id = pos(I1 , J1 ) ;
char c = a[i][j][0] ;
a[i][j] = string(100 , '0') ;
a[i][j][id] = c;
}
}
}
for(int i = 0 ; i < 3; i++){
for(int j = 0 ; j< 3 ; j++){
for(int k = 0 ; k < 100 ;k ++){
if(a[i][j][k] != '0'){
res[k] = a[i][j][k] ;
}
}
}
}
if(k == n -1){
res = calc(res) ;
}
return res ;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |