Submission #744732

# Submission time Handle Problem Language Result Execution time Memory
744732 2023-05-19T04:25:11 Z Teemka Mars (APIO22_mars) C++17
14 / 100
19 ms 2628 KB
#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
1 Correct 6 ms 2136 KB Output is correct
2 Correct 10 ms 2352 KB Output is correct
3 Correct 8 ms 2336 KB Output is correct
4 Correct 8 ms 2132 KB Output is correct
5 Correct 8 ms 2216 KB Output is correct
6 Correct 8 ms 2232 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2136 KB Output is correct
2 Correct 10 ms 2352 KB Output is correct
3 Correct 8 ms 2336 KB Output is correct
4 Correct 8 ms 2132 KB Output is correct
5 Correct 8 ms 2216 KB Output is correct
6 Correct 8 ms 2232 KB Output is correct
7 Correct 13 ms 2492 KB Output is correct
8 Correct 19 ms 2500 KB Output is correct
9 Correct 17 ms 2628 KB Output is correct
10 Correct 17 ms 2504 KB Output is correct
11 Correct 19 ms 2352 KB Output is correct
12 Correct 17 ms 2500 KB Output is correct
13 Correct 18 ms 2336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2136 KB Output is correct
2 Correct 10 ms 2352 KB Output is correct
3 Correct 8 ms 2336 KB Output is correct
4 Correct 8 ms 2132 KB Output is correct
5 Correct 8 ms 2216 KB Output is correct
6 Correct 8 ms 2232 KB Output is correct
7 Correct 13 ms 2492 KB Output is correct
8 Correct 19 ms 2500 KB Output is correct
9 Correct 17 ms 2628 KB Output is correct
10 Correct 17 ms 2504 KB Output is correct
11 Correct 19 ms 2352 KB Output is correct
12 Correct 17 ms 2500 KB Output is correct
13 Correct 18 ms 2336 KB Output is correct
14 Runtime error 1 ms 420 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2136 KB Output is correct
2 Correct 10 ms 2352 KB Output is correct
3 Correct 8 ms 2336 KB Output is correct
4 Correct 8 ms 2132 KB Output is correct
5 Correct 8 ms 2216 KB Output is correct
6 Correct 8 ms 2232 KB Output is correct
7 Correct 13 ms 2492 KB Output is correct
8 Correct 19 ms 2500 KB Output is correct
9 Correct 17 ms 2628 KB Output is correct
10 Correct 17 ms 2504 KB Output is correct
11 Correct 19 ms 2352 KB Output is correct
12 Correct 17 ms 2500 KB Output is correct
13 Correct 18 ms 2336 KB Output is correct
14 Runtime error 1 ms 420 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2136 KB Output is correct
2 Correct 10 ms 2352 KB Output is correct
3 Correct 8 ms 2336 KB Output is correct
4 Correct 8 ms 2132 KB Output is correct
5 Correct 8 ms 2216 KB Output is correct
6 Correct 8 ms 2232 KB Output is correct
7 Correct 13 ms 2492 KB Output is correct
8 Correct 19 ms 2500 KB Output is correct
9 Correct 17 ms 2628 KB Output is correct
10 Correct 17 ms 2504 KB Output is correct
11 Correct 19 ms 2352 KB Output is correct
12 Correct 17 ms 2500 KB Output is correct
13 Correct 18 ms 2336 KB Output is correct
14 Runtime error 1 ms 420 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2136 KB Output is correct
2 Correct 10 ms 2352 KB Output is correct
3 Correct 8 ms 2336 KB Output is correct
4 Correct 8 ms 2132 KB Output is correct
5 Correct 8 ms 2216 KB Output is correct
6 Correct 8 ms 2232 KB Output is correct
7 Correct 13 ms 2492 KB Output is correct
8 Correct 19 ms 2500 KB Output is correct
9 Correct 17 ms 2628 KB Output is correct
10 Correct 17 ms 2504 KB Output is correct
11 Correct 19 ms 2352 KB Output is correct
12 Correct 17 ms 2500 KB Output is correct
13 Correct 18 ms 2336 KB Output is correct
14 Runtime error 1 ms 420 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2136 KB Output is correct
2 Correct 10 ms 2352 KB Output is correct
3 Correct 8 ms 2336 KB Output is correct
4 Correct 8 ms 2132 KB Output is correct
5 Correct 8 ms 2216 KB Output is correct
6 Correct 8 ms 2232 KB Output is correct
7 Correct 13 ms 2492 KB Output is correct
8 Correct 19 ms 2500 KB Output is correct
9 Correct 17 ms 2628 KB Output is correct
10 Correct 17 ms 2504 KB Output is correct
11 Correct 19 ms 2352 KB Output is correct
12 Correct 17 ms 2500 KB Output is correct
13 Correct 18 ms 2336 KB Output is correct
14 Runtime error 1 ms 420 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2136 KB Output is correct
2 Correct 10 ms 2352 KB Output is correct
3 Correct 8 ms 2336 KB Output is correct
4 Correct 8 ms 2132 KB Output is correct
5 Correct 8 ms 2216 KB Output is correct
6 Correct 8 ms 2232 KB Output is correct
7 Correct 13 ms 2492 KB Output is correct
8 Correct 19 ms 2500 KB Output is correct
9 Correct 17 ms 2628 KB Output is correct
10 Correct 17 ms 2504 KB Output is correct
11 Correct 19 ms 2352 KB Output is correct
12 Correct 17 ms 2500 KB Output is correct
13 Correct 18 ms 2336 KB Output is correct
14 Runtime error 1 ms 420 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2136 KB Output is correct
2 Correct 10 ms 2352 KB Output is correct
3 Correct 8 ms 2336 KB Output is correct
4 Correct 8 ms 2132 KB Output is correct
5 Correct 8 ms 2216 KB Output is correct
6 Correct 8 ms 2232 KB Output is correct
7 Correct 13 ms 2492 KB Output is correct
8 Correct 19 ms 2500 KB Output is correct
9 Correct 17 ms 2628 KB Output is correct
10 Correct 17 ms 2504 KB Output is correct
11 Correct 19 ms 2352 KB Output is correct
12 Correct 17 ms 2500 KB Output is correct
13 Correct 18 ms 2336 KB Output is correct
14 Runtime error 1 ms 420 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2136 KB Output is correct
2 Correct 10 ms 2352 KB Output is correct
3 Correct 8 ms 2336 KB Output is correct
4 Correct 8 ms 2132 KB Output is correct
5 Correct 8 ms 2216 KB Output is correct
6 Correct 8 ms 2232 KB Output is correct
7 Correct 13 ms 2492 KB Output is correct
8 Correct 19 ms 2500 KB Output is correct
9 Correct 17 ms 2628 KB Output is correct
10 Correct 17 ms 2504 KB Output is correct
11 Correct 19 ms 2352 KB Output is correct
12 Correct 17 ms 2500 KB Output is correct
13 Correct 18 ms 2336 KB Output is correct
14 Runtime error 1 ms 420 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -