Submission #983367

# Submission time Handle Problem Language Result Execution time Memory
983367 2024-05-15T11:21:42 Z Jawad_Akbar_JJ Mars (APIO22_mars) C++17
14 / 100
11 ms 4364 KB
#include <iostream>
#include <vector>
#include <queue>

using namespace std;
bool seen[50][50];

int N;

vector<string> A;

bool valid(int i,int j){
	if (i >= 0 and i < N and j >= 0 and j < N and !seen[i][j] and A[i][j] == '1'){
		seen[i][j] = true;
		return true;
	}
	return false;
}

void bfs(int si,int sj){

	queue<pair<int,int>> Q;
	Q.push({si,sj});
	seen[si][sj] = 1;

	while (!Q.empty()){
		auto [i,j] = Q.front();
		Q.pop();
		if (valid(i-1,j))
			Q.push({i-1,j});
		if (valid(i+1,j))
			Q.push({i+1,j});
		if (valid(i,j+1))
			Q.push({i,j+1});
		if (valid(i,j-1))
			Q.push({i,j-1});
	}
}

string Ans(string s){

	for (int i=0;i<50;i++)
		for (int j=0;j<50;j++)
			seen[i][j] = false;
	A.clear();

	for (int i=0;i<N;i++){
		string ss;
		for (int j=0;j<N;j++)
			ss += s[i * N + j];
		A.push_back(ss);
	}
	int ans = 0;
	for (int i=0;i<N;i++){
		for (int j=0;j<N;j++)
			if (!seen[i][j] and A[i][j] == '1')
				bfs(i,j),ans++;
	}
	for (int i=0;i<100;i++)
		s[i] = '0';
	int cur = 0;
	while (ans){
		char c = char(ans % 2 + 48);
		s[cur++] = c;
		ans >>= 1;
	}
	return s;
}

string process(vector <vector<string>> a, int i, int j, int k, int n){
	N = n + n + 1;
	int m = 2 * (n - k - 1);
	int M = N - m;
	int K = M - 2;
	
	if (i == m and j == m){
		string s;
		for (int i=1;i<=100;i++)
			s += '0';
		int cur = 0;
		///////////////////////   row 1
		s[cur++] = a[0][0][0];
		s[cur++] = a[0][1][0];
		for (int i=0;i<K;i++)
			s[cur++] = a[0][2][i];
		///////////////////////   row 2
		s[cur++] = a[1][0][0];
		s[cur++] = a[1][1][0];
		for (int i=0;i<K;i++)
			s[cur++] = a[1][2][i];
		///////////////////////   row 3

		for (int i=0;i<K;i++){
			s[cur++] = a[2][0][i];
			s[cur++] = a[2][1][i];
			for (int j=0;j<K;j++)
				s[cur++] = a[2][2][i * K + j];
		}
		if (i == 0 and j == 0)
			return Ans(s);
		return s;
	}
	if (i == m){
		string s;
		for (int i=1;i<=100;i++)
			s += '0';
		s[0] = a[0][0][0];
		s[1] = a[1][0][0];
		for (int i=0;i<K;i++)
			s[2 + i] = a[2][0][i];
		return s;
	}
	if (j == m){
		string s;
		for (int i=1;i<=100;i++)
			s += '0';
		s[0] = a[0][0][0];
		s[1] = a[0][1][0];
		for (int i=0;i<K;i++)
			s[2 + i] = a[0][2][i];
		return s;
	}
	return a[0][0];
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4024 KB Output is correct
2 Correct 6 ms 3936 KB Output is correct
3 Correct 8 ms 4364 KB Output is correct
4 Correct 6 ms 3776 KB Output is correct
5 Correct 2 ms 3780 KB Output is correct
6 Correct 7 ms 4120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4024 KB Output is correct
2 Correct 6 ms 3936 KB Output is correct
3 Correct 8 ms 4364 KB Output is correct
4 Correct 6 ms 3776 KB Output is correct
5 Correct 2 ms 3780 KB Output is correct
6 Correct 7 ms 4120 KB Output is correct
7 Correct 8 ms 3604 KB Output is correct
8 Correct 8 ms 3908 KB Output is correct
9 Correct 8 ms 3860 KB Output is correct
10 Correct 9 ms 3460 KB Output is correct
11 Correct 8 ms 3604 KB Output is correct
12 Correct 8 ms 3816 KB Output is correct
13 Correct 11 ms 3972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4024 KB Output is correct
2 Correct 6 ms 3936 KB Output is correct
3 Correct 8 ms 4364 KB Output is correct
4 Correct 6 ms 3776 KB Output is correct
5 Correct 2 ms 3780 KB Output is correct
6 Correct 7 ms 4120 KB Output is correct
7 Correct 8 ms 3604 KB Output is correct
8 Correct 8 ms 3908 KB Output is correct
9 Correct 8 ms 3860 KB Output is correct
10 Correct 9 ms 3460 KB Output is correct
11 Correct 8 ms 3604 KB Output is correct
12 Correct 8 ms 3816 KB Output is correct
13 Correct 11 ms 3972 KB Output is correct
14 Incorrect 2 ms 456 KB Incorrect
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4024 KB Output is correct
2 Correct 6 ms 3936 KB Output is correct
3 Correct 8 ms 4364 KB Output is correct
4 Correct 6 ms 3776 KB Output is correct
5 Correct 2 ms 3780 KB Output is correct
6 Correct 7 ms 4120 KB Output is correct
7 Correct 8 ms 3604 KB Output is correct
8 Correct 8 ms 3908 KB Output is correct
9 Correct 8 ms 3860 KB Output is correct
10 Correct 9 ms 3460 KB Output is correct
11 Correct 8 ms 3604 KB Output is correct
12 Correct 8 ms 3816 KB Output is correct
13 Correct 11 ms 3972 KB Output is correct
14 Incorrect 2 ms 456 KB Incorrect
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4024 KB Output is correct
2 Correct 6 ms 3936 KB Output is correct
3 Correct 8 ms 4364 KB Output is correct
4 Correct 6 ms 3776 KB Output is correct
5 Correct 2 ms 3780 KB Output is correct
6 Correct 7 ms 4120 KB Output is correct
7 Correct 8 ms 3604 KB Output is correct
8 Correct 8 ms 3908 KB Output is correct
9 Correct 8 ms 3860 KB Output is correct
10 Correct 9 ms 3460 KB Output is correct
11 Correct 8 ms 3604 KB Output is correct
12 Correct 8 ms 3816 KB Output is correct
13 Correct 11 ms 3972 KB Output is correct
14 Incorrect 2 ms 456 KB Incorrect
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4024 KB Output is correct
2 Correct 6 ms 3936 KB Output is correct
3 Correct 8 ms 4364 KB Output is correct
4 Correct 6 ms 3776 KB Output is correct
5 Correct 2 ms 3780 KB Output is correct
6 Correct 7 ms 4120 KB Output is correct
7 Correct 8 ms 3604 KB Output is correct
8 Correct 8 ms 3908 KB Output is correct
9 Correct 8 ms 3860 KB Output is correct
10 Correct 9 ms 3460 KB Output is correct
11 Correct 8 ms 3604 KB Output is correct
12 Correct 8 ms 3816 KB Output is correct
13 Correct 11 ms 3972 KB Output is correct
14 Incorrect 2 ms 456 KB Incorrect
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4024 KB Output is correct
2 Correct 6 ms 3936 KB Output is correct
3 Correct 8 ms 4364 KB Output is correct
4 Correct 6 ms 3776 KB Output is correct
5 Correct 2 ms 3780 KB Output is correct
6 Correct 7 ms 4120 KB Output is correct
7 Correct 8 ms 3604 KB Output is correct
8 Correct 8 ms 3908 KB Output is correct
9 Correct 8 ms 3860 KB Output is correct
10 Correct 9 ms 3460 KB Output is correct
11 Correct 8 ms 3604 KB Output is correct
12 Correct 8 ms 3816 KB Output is correct
13 Correct 11 ms 3972 KB Output is correct
14 Incorrect 2 ms 456 KB Incorrect
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4024 KB Output is correct
2 Correct 6 ms 3936 KB Output is correct
3 Correct 8 ms 4364 KB Output is correct
4 Correct 6 ms 3776 KB Output is correct
5 Correct 2 ms 3780 KB Output is correct
6 Correct 7 ms 4120 KB Output is correct
7 Correct 8 ms 3604 KB Output is correct
8 Correct 8 ms 3908 KB Output is correct
9 Correct 8 ms 3860 KB Output is correct
10 Correct 9 ms 3460 KB Output is correct
11 Correct 8 ms 3604 KB Output is correct
12 Correct 8 ms 3816 KB Output is correct
13 Correct 11 ms 3972 KB Output is correct
14 Incorrect 2 ms 456 KB Incorrect
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4024 KB Output is correct
2 Correct 6 ms 3936 KB Output is correct
3 Correct 8 ms 4364 KB Output is correct
4 Correct 6 ms 3776 KB Output is correct
5 Correct 2 ms 3780 KB Output is correct
6 Correct 7 ms 4120 KB Output is correct
7 Correct 8 ms 3604 KB Output is correct
8 Correct 8 ms 3908 KB Output is correct
9 Correct 8 ms 3860 KB Output is correct
10 Correct 9 ms 3460 KB Output is correct
11 Correct 8 ms 3604 KB Output is correct
12 Correct 8 ms 3816 KB Output is correct
13 Correct 11 ms 3972 KB Output is correct
14 Incorrect 2 ms 456 KB Incorrect
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4024 KB Output is correct
2 Correct 6 ms 3936 KB Output is correct
3 Correct 8 ms 4364 KB Output is correct
4 Correct 6 ms 3776 KB Output is correct
5 Correct 2 ms 3780 KB Output is correct
6 Correct 7 ms 4120 KB Output is correct
7 Correct 8 ms 3604 KB Output is correct
8 Correct 8 ms 3908 KB Output is correct
9 Correct 8 ms 3860 KB Output is correct
10 Correct 9 ms 3460 KB Output is correct
11 Correct 8 ms 3604 KB Output is correct
12 Correct 8 ms 3816 KB Output is correct
13 Correct 11 ms 3972 KB Output is correct
14 Incorrect 2 ms 456 KB Incorrect
15 Halted 0 ms 0 KB -