답안 #981479

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
981479 2024-05-13T09:11:51 Z c2zi6 화성 (APIO22_mars) C++17
6 / 100
8 ms 4212 KB
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define replr(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define reprl(i, a, b) for (int i = int(a); i >= int(b); --i)
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define mkp(a, b) make_pair(a, b)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<VPI> VVPI;
typedef pair<ll, ll> PLL;
typedef vector<ll> VL;
typedef vector<PLL> VPL;
typedef vector<VL> VVL;
typedef vector<VVL> VVVL;
typedef vector<VPL> VVPL;
template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;}
template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;}
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T>
using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#include "mars.h"

void dfs(int i, int j, VVI& a, VVI& vis) {
	int n = a.size();
	vis[i][j] = true;
	if (i && !vis[i-1][j] && a[i-1][j]) dfs(i-1, j, a, vis);
	if (i+1<n && !vis[i+1][j] && a[i+1][j]) dfs(i+1, j, a, vis);
	if (j && !vis[i][j-1] && a[i][j-1]) dfs(i, j-1, a, vis);
	if (j+1<n && !vis[i][j+1] && a[i][j+1]) dfs(i, j+1, a, vis);
}
int compcnt(VVI& a) {
	int n = a.size();
	VVI vis(n, VI(n));
	int ret = 0;
	rep(i, n) rep(j, n) if (!vis[i][j] && a[i][j]) {
		dfs(i, j, a, vis);
		ret++;
	}
	return ret;
}
string tobin(int x) {
	string ret;
	while (x) {
		ret.pb('0' + (x&1));
		x >>= 1;
	}
	return ret;
}
string lracnel(string s) {
	while (s.size() < 100) s.pb('0');
	return s;
}
string answer(VVI& a) {
	return lracnel(tobin(compcnt(a)));
}

string process(vector<vector<string>> a, int i, int j, int k, int n) {
	if (n == 1) {
		VVI table(3, VI(3));
		rep(i, 3) rep(j, 3) table[i][j] = a[i][j][0]-'0';
		return answer(table);
	}
	if (n == 2) {
		if (k == 0) {
			string ret;
			rep(i, 3) rep(j, 3) ret.pb(a[i][j][0]);
			return lracnel(ret);
		} else {
			VVI table(5, VI(5));
			rep(i, 3) rep(j, 3) {
				int cur = 0;
				replr(i1, i, i+2) replr(j1, j, j+2) {
					table[i1][j1] = a[i][j][cur++]-'0';
				}
			}
			return answer(table);
		}
	}
	return lracnel("");
}





# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4112 KB Output is correct
2 Correct 7 ms 3880 KB Output is correct
3 Correct 8 ms 4112 KB Output is correct
4 Correct 5 ms 4020 KB Output is correct
5 Correct 5 ms 3600 KB Output is correct
6 Correct 8 ms 4212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4112 KB Output is correct
2 Correct 7 ms 3880 KB Output is correct
3 Correct 8 ms 4112 KB Output is correct
4 Correct 5 ms 4020 KB Output is correct
5 Correct 5 ms 3600 KB Output is correct
6 Correct 8 ms 4212 KB Output is correct
7 Incorrect 1 ms 332 KB Incorrect
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4112 KB Output is correct
2 Correct 7 ms 3880 KB Output is correct
3 Correct 8 ms 4112 KB Output is correct
4 Correct 5 ms 4020 KB Output is correct
5 Correct 5 ms 3600 KB Output is correct
6 Correct 8 ms 4212 KB Output is correct
7 Incorrect 1 ms 332 KB Incorrect
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4112 KB Output is correct
2 Correct 7 ms 3880 KB Output is correct
3 Correct 8 ms 4112 KB Output is correct
4 Correct 5 ms 4020 KB Output is correct
5 Correct 5 ms 3600 KB Output is correct
6 Correct 8 ms 4212 KB Output is correct
7 Incorrect 1 ms 332 KB Incorrect
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4112 KB Output is correct
2 Correct 7 ms 3880 KB Output is correct
3 Correct 8 ms 4112 KB Output is correct
4 Correct 5 ms 4020 KB Output is correct
5 Correct 5 ms 3600 KB Output is correct
6 Correct 8 ms 4212 KB Output is correct
7 Incorrect 1 ms 332 KB Incorrect
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4112 KB Output is correct
2 Correct 7 ms 3880 KB Output is correct
3 Correct 8 ms 4112 KB Output is correct
4 Correct 5 ms 4020 KB Output is correct
5 Correct 5 ms 3600 KB Output is correct
6 Correct 8 ms 4212 KB Output is correct
7 Incorrect 1 ms 332 KB Incorrect
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4112 KB Output is correct
2 Correct 7 ms 3880 KB Output is correct
3 Correct 8 ms 4112 KB Output is correct
4 Correct 5 ms 4020 KB Output is correct
5 Correct 5 ms 3600 KB Output is correct
6 Correct 8 ms 4212 KB Output is correct
7 Incorrect 1 ms 332 KB Incorrect
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4112 KB Output is correct
2 Correct 7 ms 3880 KB Output is correct
3 Correct 8 ms 4112 KB Output is correct
4 Correct 5 ms 4020 KB Output is correct
5 Correct 5 ms 3600 KB Output is correct
6 Correct 8 ms 4212 KB Output is correct
7 Incorrect 1 ms 332 KB Incorrect
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4112 KB Output is correct
2 Correct 7 ms 3880 KB Output is correct
3 Correct 8 ms 4112 KB Output is correct
4 Correct 5 ms 4020 KB Output is correct
5 Correct 5 ms 3600 KB Output is correct
6 Correct 8 ms 4212 KB Output is correct
7 Incorrect 1 ms 332 KB Incorrect
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4112 KB Output is correct
2 Correct 7 ms 3880 KB Output is correct
3 Correct 8 ms 4112 KB Output is correct
4 Correct 5 ms 4020 KB Output is correct
5 Correct 5 ms 3600 KB Output is correct
6 Correct 8 ms 4212 KB Output is correct
7 Incorrect 1 ms 332 KB Incorrect
8 Halted 0 ms 0 KB -