답안 #1083887

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1083887 2024-09-04T12:34:25 Z alexander707070 화성 (APIO22_mars) C++17
14 / 100
14 ms 3312 KB
#include<bits/stdc++.h>
#include "mars.h"

using namespace std;

int n;
char t[50][50];
bool vis[50][50];

void reset(){
	for(int i=0;i<2*n+1;i++){
		for(int f=0;f<2*n+1;f++){
			vis[i][f]=false;
		}
	}
}

void dfs(int x,int y){
	vis[x][y]=true;

	if(x>0 and !vis[x-1][y] and t[x-1][y]=='1')dfs(x-1,y);
	if(y>0 and !vis[x][y-1] and t[x][y-1]=='1')dfs(x,y-1);
	if(x<2*n+1 and !vis[x+1][y] and t[x+1][y]=='1')dfs(x+1,y);
	if(y<2*n+1 and !vis[x][y+1] and t[x][y+1]=='1')dfs(x,y+1);
}

string tostr(int x){
	string res="";
	for(int i=0;i<100;i++){
		res.push_back(x%2+'0');
		x/=2;
	}
	return res;
}

string solve(){
	reset();

	int ans=0;
	for(int i=0;i<2*n+1;i++){
		for(int f=0;f<2*n+1;f++){
			if(t[i][f]=='1' and !vis[i][f]){
				dfs(i,f); ans++;
			}
		}
	}

	return tostr(ans);
}

string process(vector< vector<string> > a, int x, int y, int k, int N){
	n=N;

	int m=2*(n-k-1);
	if(x<m and y<m)return a[0][0];

	for(int i=m;i<=m+1;i++){
		for(int f=m;f<=m+1;f++){
			t[i][f]=a[i-m][f-m][0];
		}
	}

	for(int s=0;s<=2;s++){
		for(int d=0;d<=2;d++){
			int pt=0;

			int diff=min(2*n+1-m-s,2*n+1-m-d);

			for(int i=m+s;i<m+s+diff;i++){
				for(int f=m+d;f<m+d+diff;f++){
					if(s!=2 and d!=2)continue;

					t[i][f]=a[s][d][pt];
					pt++;
				}
			}
		}
	}

	if(k==n-1){
		return solve();
	}else{		
		int pt=0;
		for(int i=m;i<2*n+1;i++){
			for(int f=m;f<2*n+1;f++){
				a[0][0][pt]=t[i][f];
				pt++;
			}
		}

		return a[0][0];
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 2852 KB Output is correct
2 Correct 8 ms 2848 KB Output is correct
3 Correct 6 ms 2760 KB Output is correct
4 Correct 7 ms 2940 KB Output is correct
5 Correct 4 ms 3312 KB Output is correct
6 Correct 7 ms 3148 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 2852 KB Output is correct
2 Correct 8 ms 2848 KB Output is correct
3 Correct 6 ms 2760 KB Output is correct
4 Correct 7 ms 2940 KB Output is correct
5 Correct 4 ms 3312 KB Output is correct
6 Correct 7 ms 3148 KB Output is correct
7 Correct 8 ms 3136 KB Output is correct
8 Correct 8 ms 2928 KB Output is correct
9 Correct 9 ms 2972 KB Output is correct
10 Correct 10 ms 3116 KB Output is correct
11 Correct 14 ms 2848 KB Output is correct
12 Correct 14 ms 2840 KB Output is correct
13 Correct 9 ms 3052 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 2852 KB Output is correct
2 Correct 8 ms 2848 KB Output is correct
3 Correct 6 ms 2760 KB Output is correct
4 Correct 7 ms 2940 KB Output is correct
5 Correct 4 ms 3312 KB Output is correct
6 Correct 7 ms 3148 KB Output is correct
7 Correct 8 ms 3136 KB Output is correct
8 Correct 8 ms 2928 KB Output is correct
9 Correct 9 ms 2972 KB Output is correct
10 Correct 10 ms 3116 KB Output is correct
11 Correct 14 ms 2848 KB Output is correct
12 Correct 14 ms 2840 KB Output is correct
13 Correct 9 ms 3052 KB Output is correct
14 Runtime error 3 ms 580 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 2852 KB Output is correct
2 Correct 8 ms 2848 KB Output is correct
3 Correct 6 ms 2760 KB Output is correct
4 Correct 7 ms 2940 KB Output is correct
5 Correct 4 ms 3312 KB Output is correct
6 Correct 7 ms 3148 KB Output is correct
7 Correct 8 ms 3136 KB Output is correct
8 Correct 8 ms 2928 KB Output is correct
9 Correct 9 ms 2972 KB Output is correct
10 Correct 10 ms 3116 KB Output is correct
11 Correct 14 ms 2848 KB Output is correct
12 Correct 14 ms 2840 KB Output is correct
13 Correct 9 ms 3052 KB Output is correct
14 Runtime error 3 ms 580 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 2852 KB Output is correct
2 Correct 8 ms 2848 KB Output is correct
3 Correct 6 ms 2760 KB Output is correct
4 Correct 7 ms 2940 KB Output is correct
5 Correct 4 ms 3312 KB Output is correct
6 Correct 7 ms 3148 KB Output is correct
7 Correct 8 ms 3136 KB Output is correct
8 Correct 8 ms 2928 KB Output is correct
9 Correct 9 ms 2972 KB Output is correct
10 Correct 10 ms 3116 KB Output is correct
11 Correct 14 ms 2848 KB Output is correct
12 Correct 14 ms 2840 KB Output is correct
13 Correct 9 ms 3052 KB Output is correct
14 Runtime error 3 ms 580 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 2852 KB Output is correct
2 Correct 8 ms 2848 KB Output is correct
3 Correct 6 ms 2760 KB Output is correct
4 Correct 7 ms 2940 KB Output is correct
5 Correct 4 ms 3312 KB Output is correct
6 Correct 7 ms 3148 KB Output is correct
7 Correct 8 ms 3136 KB Output is correct
8 Correct 8 ms 2928 KB Output is correct
9 Correct 9 ms 2972 KB Output is correct
10 Correct 10 ms 3116 KB Output is correct
11 Correct 14 ms 2848 KB Output is correct
12 Correct 14 ms 2840 KB Output is correct
13 Correct 9 ms 3052 KB Output is correct
14 Runtime error 3 ms 580 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 2852 KB Output is correct
2 Correct 8 ms 2848 KB Output is correct
3 Correct 6 ms 2760 KB Output is correct
4 Correct 7 ms 2940 KB Output is correct
5 Correct 4 ms 3312 KB Output is correct
6 Correct 7 ms 3148 KB Output is correct
7 Correct 8 ms 3136 KB Output is correct
8 Correct 8 ms 2928 KB Output is correct
9 Correct 9 ms 2972 KB Output is correct
10 Correct 10 ms 3116 KB Output is correct
11 Correct 14 ms 2848 KB Output is correct
12 Correct 14 ms 2840 KB Output is correct
13 Correct 9 ms 3052 KB Output is correct
14 Runtime error 3 ms 580 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 2852 KB Output is correct
2 Correct 8 ms 2848 KB Output is correct
3 Correct 6 ms 2760 KB Output is correct
4 Correct 7 ms 2940 KB Output is correct
5 Correct 4 ms 3312 KB Output is correct
6 Correct 7 ms 3148 KB Output is correct
7 Correct 8 ms 3136 KB Output is correct
8 Correct 8 ms 2928 KB Output is correct
9 Correct 9 ms 2972 KB Output is correct
10 Correct 10 ms 3116 KB Output is correct
11 Correct 14 ms 2848 KB Output is correct
12 Correct 14 ms 2840 KB Output is correct
13 Correct 9 ms 3052 KB Output is correct
14 Runtime error 3 ms 580 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 2852 KB Output is correct
2 Correct 8 ms 2848 KB Output is correct
3 Correct 6 ms 2760 KB Output is correct
4 Correct 7 ms 2940 KB Output is correct
5 Correct 4 ms 3312 KB Output is correct
6 Correct 7 ms 3148 KB Output is correct
7 Correct 8 ms 3136 KB Output is correct
8 Correct 8 ms 2928 KB Output is correct
9 Correct 9 ms 2972 KB Output is correct
10 Correct 10 ms 3116 KB Output is correct
11 Correct 14 ms 2848 KB Output is correct
12 Correct 14 ms 2840 KB Output is correct
13 Correct 9 ms 3052 KB Output is correct
14 Runtime error 3 ms 580 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 2852 KB Output is correct
2 Correct 8 ms 2848 KB Output is correct
3 Correct 6 ms 2760 KB Output is correct
4 Correct 7 ms 2940 KB Output is correct
5 Correct 4 ms 3312 KB Output is correct
6 Correct 7 ms 3148 KB Output is correct
7 Correct 8 ms 3136 KB Output is correct
8 Correct 8 ms 2928 KB Output is correct
9 Correct 9 ms 2972 KB Output is correct
10 Correct 10 ms 3116 KB Output is correct
11 Correct 14 ms 2848 KB Output is correct
12 Correct 14 ms 2840 KB Output is correct
13 Correct 9 ms 3052 KB Output is correct
14 Runtime error 3 ms 580 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -