답안 #725255

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
725255 2023-04-17T05:23:48 Z Nahian9696 화성 (APIO22_mars) C++17
컴파일 오류
0 ms 0 KB
#include "mars.h"


#include <bits/stdc++.h>

using namespace std;

#define int  				long long

#define f0(i, n) 			for(int i = 0; i <  (n); i++)
#define f1(i, n) 			for(int i = 1; i <= (n); i++)
#define ff first
#define ss second





std::string process(std::vector <std::vector<std::string>> a, int i, int j, int k, int n)
{
	string res;
	f0(i, 100) res += '0';

	int ii = i/2, jj = j/2;


	if(k == 0) {
		if( (i % 2 == 0) && (j % 2 == 0) ) {

			if(a[0][0][0] == '1') {
				a[0][0] = res;
				a[0][0][ (n+1)*(jj) + (ii) ] = '1';
			} else {
				a[0][0] = res;
			}

			if(a[0][2][0] == '1') {
				a[0][0] = res;
				a[0][0][ (n+1)*(jj+1) + (ii) ] = '1';
			} else {
				a[0][0] = res;
			}

			if(a[2][0][0] == '1') {
				a[0][0] = res;
				a[0][0][ (n+1)*(jj) + (ii+1) ] = '1';
			} else {
				a[0][0] = res;
			}

			if(a[2][2][0] == '1') {
				a[0][0] = res;
				a[0][0][ (n+1)*(jj+1) + (ii+1) ] = '1';
			} else {
				a[0][0] = res;
			}

		} else if( (i % 2 == 1) && (j % 2 == 0) ) {

			if(a[0][0][0] == '1') {
				a[0][0] = res;
				a[0][0][ (n)*(jj) + (ii) ] = '1';
			} else {
				a[0][0] = res;
			}

			if(a[0][2][0] == '1') {
				a[0][0] = res;
				a[0][0][ (n)*(jj+1) + (ii) ] = '1';
			} else {
				a[0][0] = res;
			}

			if(a[2][0][0] == '1') {
				a[0][0] = res;
				a[0][0][ (n)*(jj) + (ii+1) ] = '1';
			} else {
				a[0][0] = res;
			}

			if(a[2][2][0] == '1') {
				a[0][0] = res;
				a[0][0][ (n)*(jj+1) + (ii+1) ] = '1';
			} else {
				a[0][0] = res;
			}

		} else if( (i % 2 == 0) && (j % 2 == 1) ) {

			if(a[0][0][0] == '1') {
				a[0][0] = res;
				a[0][0][ (n+1)*(jj) + (ii) ] = '1';
			} else {
				a[0][0] = res;
			}

			if(a[0][2][0] == '1') {
				a[0][0] = res;
				a[0][0][ (n+1)*(jj+1) + (ii) ] = '1';
			} else {
				a[0][0] = res;
			}

			if(a[2][0][0] == '1') {
				a[0][0] = res;
				a[0][0][ (n+1)*(jj) + (ii+1) ] = '1';
			} else {
				a[0][0] = res;
			}

			if(a[2][2][0] == '1') {
				a[0][0] = res;
				a[0][0][ (n+1)*(jj+1) + (ii+1) ] = '1';
			} else {
				a[0][0] = res;
			}

		} else if( (i % 2 == 1) && (j % 2 == 1) ) {

			if(a[0][0][0] == '1') {
				a[0][0] = res;
				a[0][0][ (n)*(jj) + (ii) ] = '1';
			} else {
				a[0][0] = res;
			}

			if(a[0][2][0] == '1') {
				a[0][0] = res;
				a[0][0][ (n)*(jj+1) + (ii) ] = '1';
			} else {
				a[0][0] = res;
			}

			if(a[2][0][0] == '1') {
				a[0][0] = res;
				a[0][0][ (n)*(jj) + (ii+1) ] = '1';
			} else {
				a[0][0] = res;
			}

			if(a[2][2][0] == '1') {
				a[0][0] = res;
				a[0][0][ (n)*(jj+1) + (ii+1) ] = '1';
			} else {
				a[0][0] = res;
			}

		}
	}


	f0(i, 100) {
		if (
			(a[0][0][i] == '1') ||
			(a[2][0][i] == '1') ||
			(a[0][2][i] == '1') ||
			(a[2][2][i] == '1')
			) {
			res[i] = '1';
		}
	}

	if(k == n-1) {


		bool grph[2*n+1][2*n+1] = {0};
		bool vis[2*n+1][2*n+1] = {0};
		int cnt = 0;

		f0(i, (n+1)*(n+1)) {
			int y = i/(n+1), x = i % (n+1);

			if(a[0][0][i] == '1') {
				grph[2*x][2*y] = 1;
			}
		}

		f0(i, n*(n+1)) {
			int y = i/(n+1), x = i % (n+1);

			if(a[0][0][i] == '1') {
				grph[2*x][2*y+1] = 1;
			}
		}

		f0(i, (n+1)*n) {
			int y = i/n, x = i % n;

			if(a[0][0][i] == '1') {
				grph[2*x+1][2*y] = 1;
			}
		}

		f0(i, n*n) {
			int y = i/n, x = i % n;

			if(a[0][0][i] == '1') {
				grph[2*x+1][2*y+1] = 1;
			}
		}



		queue<pair<int, int>> q;

		f0(i, 2*n+1) {
			f0(j, 2*n+1) {
				if(vis[i][j]) continue;
				vis[i][j] = 1;
				cnt++;
				q.push({i, j});
				while(!q.empty()) {
					auto cur = q.front();
					int x = cur.ff, y = cur.ss;
					q.pop();
					if(x+1 < 2*n+1) {
						if(grph[x+1][y] == 1) {
							if(!vis[x+1][y]) {
								vis[x+1][y] = 1;
								q.push({x+1, y});
							}
						}
					}
					if(y+1 < 2*n+1) {
						if(grph[x][y+1] == 1) {
							if(!vis[x][y+1]) {
								vis[x][y+1] = 1;
								q.push({x, y+1});
							}
						}
					}
					if(x > 0) {
						if(grph[x-1][y] == 1) {
							if(!vis[x-1][y]) {
								vis[x-1][y] = 1;
								q.push({x-1, y});
							}
						}
					}
					if(y > 0) {
						if(grph[x][y-1] == 1) {
							if(!vis[x][y-1]) {
								vis[x][y-1] = 1;
								q.push({x, y-1});
							}
						}
					}
				}
			}
		}

		res = bitset<100> (cnt).to_string();

	}

	return res;

	return std::string(100 ,'0');
}

Compilation message

/usr/bin/ld: /tmp/cc8DQ6Jt.o: in function `main':
stub.cpp:(.text.startup+0x793): undefined reference to `process(std::vector<std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, std::allocator<std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > >, int, int, int, int)'
collect2: error: ld returned 1 exit status