Submission #594775

#TimeUsernameProblemLanguageResultExecution timeMemory
594775OzyMars (APIO22_mars)C++17
0 / 100
1 ms308 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 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; lli I = i/2; lli J = j/2; if (k == 0) { rep(x,0,2) { rep(y,0,2) { pos = (x+I)*largo + (J+y); if (A[x][y][pos] == '0') A[x][y][pos] = A[x][y][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; arr[x][y] = 0; } } 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]) continue; if (arr[x][y] == 1) { res++; marca(x,y); } } } 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...