Submission #594805

#TimeUsernameProblemLanguageResultExecution timeMemory
594805OzyMars (APIO22_mars)C++17
29 / 100
126 ms3048 KiB
#include "mars.h" #include <bits/stdc++.h> using namespace std; #define rep(i,a,b) for (int i = (a); i <= (b); i++) #define repa(i,a,b) for (int i = (a); i >= (b); i--) #define lli long long int #define debug(a) cout << #a << " = " << a << endl #define debugsl(a) cout << #a << " = " << a << ", " #define inicio "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" vector <std::vector<std::string>> A; lli arr[22][22],visitados[22][22]; lli res; void llena(string mapa, lli fil, lli col) { lli i,j; rep(act,0,99) { i = act/10; i *= 2; i += 1+fil; j = act%10; j *= 2; j += 1+col; if (mapa[act] == '1') arr[i][j] = 1; } } void marca(lli fil, lli col) { lli x,y; visitados[fil][col] = 1; x = fil+1; y = col; if (arr[x][y] == 1 && visitados[x][y] == 0) marca(x,y); x = fil-1; y = col; if (arr[x][y] == 1 && visitados[x][y] == 0) marca(x,y); x = fil; y = col+1; if (arr[x][y] == 1 && visitados[x][y] == 0) marca(x,y); x = fil; y = col-1; if (arr[x][y] == 1 && visitados[x][y] == 0) marca(x,y); } std::string process(std::vector <std::vector<std::string>> a, int i, int j, int k, int n) { swap(A,a); string st = inicio; lli pos,largo = 10; if (k == 0) { rep(x,0,2) { rep(y,0,2) { lli I = (i+x)/2; lli J = (j+y)/2; pos = I*largo + J; if (A[x][y][pos] == '0') A[x][y][pos] = A[x][y][0]; if (pos != 0) A[x][y][0] = '0'; } } } rep(q,0,99) if (A[0][0][q] == '1' || A[2][0][q] == '1' || A[0][2][q] == '1' || A[2][2][q] == '1') st[q] = '1'; if (k < n-1) return st; rep(x,0,21) { rep(y,0,21) { arr[x][y] = 0; visitados[x][y] = 0; } } A[0][0] = st; rep(q,0,99) A[0][1][q] = A[0][1][q] | A[2][1][q]; rep(q,0,99) A[1][0][q] = A[1][0][q] | A[1][2][q]; llena(A[0][0],0,0); llena(A[0][1],0,1); llena(A[1][0],1,0); llena(A[1][1],1,1); res = 0; rep(x,1,20) { rep(y,1,20) { if (visitados[x][y] == 1) continue; if (arr[x][y] == 1) { res++; marca(x,y); } } } //rep(x,1,20) { // rep(y,1,20) { // cout << arr[x][y]; // } // cout << endl; //} string fin = inicio; lli cont = 0; while (res > 0) { if (res&1) fin[cont] = '1'; res /= 2; cont++; } return fin; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...