Submission #1200153

#TimeUsernameProblemLanguageResultExecution timeMemory
1200153browntoadMars (APIO22_mars)C++20
14 / 100
8 ms3304 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
// #define int ll
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, n+1)
#define RREP(i, n) for (int i = (n)-1; i >= 0; i--)
#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)((x).size())

namespace{
    const ll maxn = 25;
    const ll mod = 1e9+7;
    const ll inf = (1ll<<60);

	vector<int> dx = {1, 0, -1, 0};
	vector<int> dy = {0, 1, 0, -1};
}

vector<int> par;
int fin(int a){
	if (a == par[a]) return a;
	return par[a] = fin(par[a]);
}
void merg(int a, int b){
	a = fin(a); b = fin(b);
	par[a] = b;
}

string genans(int n, vector<vector<int>> arr){
	// dimensions are 2n+1 by 2n+1
	int moo = (2*n+1) * (2*n+1);
	int len = 2*n+1;

	par = vector<int> (moo);
	REP(i, moo) par[i] = i;
	REP(i, len){
		REP(j, len){
			if (arr[i][j] == 0) continue;
			REP(k, 4){
				int ni = i+dx[k], nj = j+dy[k];
				if (ni >= 0 && nj >= 0 && ni < len && nj < len && arr[ni][nj] == 1){
					merg(i*len + j, ni*len + nj);
				}
			}
		}
	}

	set<int> st;
	REP(i, len){
		REP(j, len){
			if (arr[i][j]) st.insert(fin(i*len + j));
		}
	}
	int ret = SZ(st);

	string acc;
	REP(i, 100){
		if (i < 30 && ((ret>>i)&1)) acc += '1';
		else acc += '0';
	}
	return acc;
}
std::string process(std::vector <std::vector<std::string>> arr, int i, int j, int k, int n){
	int len = 2*n+1;
	int moo = len * len;

	// bits stored 1 base
	REP(a, 3){
		REP(b, 3){
			int ni = a + i, nj = b + j;
			int cores = ni*len + nj + 1;
			if (arr[a][b][0] == '1'){
				arr[0][0][cores] = '1';
			}

			REP1(t, moo){
				if (arr[a][b][t] == '1') {
					arr[0][0][t] = '1'; // or
				}
			}
		}
	}

	if (k == n-1){ // end
		vector<vector<int>> tmp;
		REP(i, len){
			tmp.pb({});
			REP(j, len){
				if (arr[0][0][i*len + j + 1] == '1') tmp.back().pb(1);
				else tmp.back().pb(0);
			}
		}
		return genans(n, tmp);
	}
	else{
		return arr[0][0];
	}
}
#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...