제출 #703369

#제출 시각아이디문제언어결과실행 시간메모리
703369minhcool화성 (APIO22_mars)C++17
14 / 100
17 ms2348 KiB
#include "mars.h"
#include<bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;

const int N = 105;

const int oo = 1e18 + 7, mod = 1e9 + 7;

int n, a[N];

bool b[N][N];

//int xx[] = {0, 1, -1, 0};
//int yy[] = {1, 0, 0, -1};

bool vis[N][N];

void ff(int i, int j, int n){
	if(i < 0 || j < 0 || i >= n || j >= n || b[i][j] != 1 || vis[i][j]) return; 
	vis[i][j] = 1;
	ff(i + 1, j, n);
	ff(i - 1, j, n);
	ff(i, j - 1, n);
	ff(i, j + 1, n);
}

string process(vector<vector<string>> a, int x, int y, int k, int n)
{
	if(!k){
		for(int i = 0; i < 3; i++){
			for(int j = 0; j < 3; j++){
				if(a[i][j][0] == '1'){
					a[i][j][0] = '0';
					a[i][j][((x + i) * 10) + (y + j)] = '1';
				}
			}
		}
	}
	string temp = "";
	temp.resize(100);
	for(int i = 0; i < 100; i++) temp[i] = '0';
	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] == '1') temp[k] = '1';
		}
	}
	//cout << temp << "\n";
	for(int i = 0; i < 100; i++) b[i/10][i%10] = '0';
	for(int i = 0; i < 100; i++){
		//cout << i << " " << (i / 10) << " " << (i % 10) << " " << b[i/10][i%10] << " " << temp[i] << "\n";
		b[i / 10][i % 10] = temp[i] - '0';
	}
	if(k == (n - 1)){
		for(int i = 0; i <= 2 * n; i++){
			for(int j = 0; j <= 2 * n; j++) vis[i][j] = 0;
		}	
		int answer = 0;
		for(int i = 0; i <= (2 * n); i++){
			for(int j = 0; j <= (2 * n); j++){
				//cout << b[i][j];
				if(!vis[i][j] && b[i][j] == 1){
					answer++;
					ff(i, j, 2 * n + 1);
				}
				//cout << "\n";
			}
			//cout << "\n";
		}
		//cout << answer << "\n";
		string tempo = "";
		for(int i = 0; i < 100; i++) tempo += "0";
		for(int i = 0; i < 10; i++) if(answer & (1LL << i)) tempo[i] = '1';
		return tempo;
	}
	else return temp;
}

/*
signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	process();
}*/

컴파일 시 표준 에러 (stderr) 메시지

mars.cpp:16:21: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   16 | const int oo = 1e18 + 7, mod = 1e9 + 7;
      |                ~~~~~^~~
#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...