답안 #982709

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
982709 2024-05-14T16:26:40 Z vjudge1 화성 (APIO22_mars) C++17
14 / 100
9 ms 4276 KB
#include "mars.h"
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define deb(x) cout<<#x<<": "<<x<<endl;
string process(vector <vector<string>> a, int i, int j, int k, int n)
{
//	deb(i);
//	deb(j);
//	deb(k);
	string ans="";
	if(n==1){
		int cont=1;
		queue<pair<int,pair<int,int>>> q;
		vector<vector<int>> grid (a.size(), vector<int> (a.size(), 0));
		for(int i=0; i<a.size(); ++i){
			for(int j=0;j<a.size(); ++j){
				grid[i][j]=a[i][j][0]-'0';
			}
		}
		for(int i=0; i<a.size(); ++i){
			for(int j=0; j<a.size(); ++j){
				if(grid[i][j]==1){
					cont++;
					q.push({cont,{i,j}});
					while(!q.empty()){
						int a=q.front().first;
						int b=q.front().second.first;
						int c=q.front().second.second;
						q.pop();
						if(grid[b][c]!=1) continue;
						grid[b][c]=a;
						if(b-1>=0){
							if(grid[b-1][c]==1){
								q.push({a, {b-1,c}});
							}
						}
						if(c+1<grid.size()){
							if(grid[b][c+1]==1){
								q.push({a, {b,c+1}});
							}
						}
						if(b+1<grid.size()){
							if(grid[b+1][c]==1){
								q.push({a, {b+1,c}});
							}
						}
						if(c-1>=0){
							if(grid[b][c-1]==1){
								q.push({a, {b, c-1}});
							}
						}
					}
				}
			}
		}
		cont--;
		for(int i=0; i<100; ++i){
			if(cont%2==0){
				ans+='0';
			}
			else{
				ans+='1';
			}
			cont/=2;
		}
		return ans;

	}
	if(k!=n-1){
		for(int i=0; i<=2; ++i){
			if(i!=2){

				for(int j=0; j<=2; ++j){
					if(j!=2){
						ans+=a[i][j][0];
					}
					else{
						for(int x=0; x<2*k+1; ++x){
							ans+=a[i][j][x];
						}
					}
				}
				
			}
			else{
				for(int j=0; j<2*k+1; ++j){
					for(int x=0; x<=2; ++x){
						if(x!=2){
							ans+=a[i][x][(2*k+1)*j];
						}
						else{
							for(int l=0; l<2*k+1; ++l){
								ans+=a[i][x][(2*k+1)*j+l];
							}
						}
					}
				}
			}
		}
		while(ans.size()<100){
			ans+='0';
		}
		return ans;
	}
	vector<vector<int>> grid (2*n+1, vector<int> (2*n+1, 0));	
	for(int i=0; i<=2; ++i){
			if(i!=2){
				for(int j=0; j<=2; ++j){
					if(j!=2){
						grid[i][j]=a[i][j][0]-'0';
					}
					else{
						for(int x=0; x<2*k+1; ++x){
							grid[i][x+2]=a[i][j][x]-'0';
						}
					}
				}
			}
			else{
				for(int j=0; j<2*k+1; ++j){
					for(int x=0; x<=2; ++x){
						if(x!=2){
							grid[i+j][x]=a[i][x][(2*k+1)*j]-'0';
						}
						else{
							for(int l=0; l<2*k+1; ++l){
								grid[i+j][x+l]=a[i][x][(2*k+1)*j+l]-'0';
							}
						}
					}
				}
			}
		}
	//	deb("hlp");
		int cont=1;
		queue<pair<int,pair<int,int>>>q;
		for(int i=0; i<grid.size(); ++i){
			for(int j=0; j<grid.size(); ++j){
	//			deb(i);
	//			deb(j);
	//			deb(grid[i][j]);
				if(grid[i][j]==1){
					cont++;
					q.push({cont,{i,j}});
					while(!q.empty()){
						int a=q.front().first;
						int b=q.front().second.first;
						int c=q.front().second.second;
						q.pop();
	//					deb(a);
	//					deb(b);
	//					deb(c);
						if(grid[b][c]!=1) continue;
						grid[b][c]=a;
						if(b-1>=0){
							if(grid[b-1][c]==1){
								q.push({a, {b-1,c}});
							}
						}
						if(c+1<grid.size()){
							if(grid[b][c+1]==1){
								q.push({a, {b,c+1}});
							}
						}
						if(b+1<grid.size()){
							if(grid[b+1][c]==1){
								q.push({a, {b+1,c}});
							}
						}
						if(c-1>=0){
							if(grid[b][c-1]==1){
								q.push({a, {b, c-1}});
							}
						}
					}
				}
			}
		}
	//	deb("hlp2");
		cont--;

		for(int i=0; i<100; ++i){
			if(cont%2==0){
				ans+='0';
			}
			else{
				ans+='1';
			}
			cont/=2;
		}
		return ans;
}

Compilation message

mars.cpp: In function 'std::string process(std::vector<std::vector<std::__cxx11::basic_string<char> > >, int, int, int, int)':
mars.cpp:16:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<std::__cxx11::basic_string<char> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |   for(int i=0; i<a.size(); ++i){
      |                ~^~~~~~~~~
mars.cpp:17:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<std::__cxx11::basic_string<char> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |    for(int j=0;j<a.size(); ++j){
      |                ~^~~~~~~~~
mars.cpp:21:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<std::__cxx11::basic_string<char> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |   for(int i=0; i<a.size(); ++i){
      |                ~^~~~~~~~~
mars.cpp:22:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<std::__cxx11::basic_string<char> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |    for(int j=0; j<a.size(); ++j){
      |                 ~^~~~~~~~~
mars.cpp:38:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |       if(c+1<grid.size()){
      |          ~~~^~~~~~~~~~~~
mars.cpp:43:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |       if(b+1<grid.size()){
      |          ~~~^~~~~~~~~~~~
mars.cpp:138:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  138 |   for(int i=0; i<grid.size(); ++i){
      |                ~^~~~~~~~~~~~
mars.cpp:139:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  139 |    for(int j=0; j<grid.size(); ++j){
      |                 ~^~~~~~~~~~~~
mars.cpp:161:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  161 |       if(c+1<grid.size()){
      |          ~~~^~~~~~~~~~~~
mars.cpp:166:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  166 |       if(b+1<grid.size()){
      |          ~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 4112 KB Output is correct
2 Correct 7 ms 4112 KB Output is correct
3 Correct 7 ms 4276 KB Output is correct
4 Correct 5 ms 3772 KB Output is correct
5 Correct 6 ms 3940 KB Output is correct
6 Correct 6 ms 3768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 4112 KB Output is correct
2 Correct 7 ms 4112 KB Output is correct
3 Correct 7 ms 4276 KB Output is correct
4 Correct 5 ms 3772 KB Output is correct
5 Correct 6 ms 3940 KB Output is correct
6 Correct 6 ms 3768 KB Output is correct
7 Correct 8 ms 3852 KB Output is correct
8 Correct 8 ms 3888 KB Output is correct
9 Correct 9 ms 3940 KB Output is correct
10 Correct 8 ms 4132 KB Output is correct
11 Correct 8 ms 3772 KB Output is correct
12 Correct 8 ms 3944 KB Output is correct
13 Correct 9 ms 4128 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 4112 KB Output is correct
2 Correct 7 ms 4112 KB Output is correct
3 Correct 7 ms 4276 KB Output is correct
4 Correct 5 ms 3772 KB Output is correct
5 Correct 6 ms 3940 KB Output is correct
6 Correct 6 ms 3768 KB Output is correct
7 Correct 8 ms 3852 KB Output is correct
8 Correct 8 ms 3888 KB Output is correct
9 Correct 9 ms 3940 KB Output is correct
10 Correct 8 ms 4132 KB Output is correct
11 Correct 8 ms 3772 KB Output is correct
12 Correct 8 ms 3944 KB Output is correct
13 Correct 9 ms 4128 KB Output is correct
14 Incorrect 2 ms 452 KB invalid len
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 4112 KB Output is correct
2 Correct 7 ms 4112 KB Output is correct
3 Correct 7 ms 4276 KB Output is correct
4 Correct 5 ms 3772 KB Output is correct
5 Correct 6 ms 3940 KB Output is correct
6 Correct 6 ms 3768 KB Output is correct
7 Correct 8 ms 3852 KB Output is correct
8 Correct 8 ms 3888 KB Output is correct
9 Correct 9 ms 3940 KB Output is correct
10 Correct 8 ms 4132 KB Output is correct
11 Correct 8 ms 3772 KB Output is correct
12 Correct 8 ms 3944 KB Output is correct
13 Correct 9 ms 4128 KB Output is correct
14 Incorrect 2 ms 452 KB invalid len
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 4112 KB Output is correct
2 Correct 7 ms 4112 KB Output is correct
3 Correct 7 ms 4276 KB Output is correct
4 Correct 5 ms 3772 KB Output is correct
5 Correct 6 ms 3940 KB Output is correct
6 Correct 6 ms 3768 KB Output is correct
7 Correct 8 ms 3852 KB Output is correct
8 Correct 8 ms 3888 KB Output is correct
9 Correct 9 ms 3940 KB Output is correct
10 Correct 8 ms 4132 KB Output is correct
11 Correct 8 ms 3772 KB Output is correct
12 Correct 8 ms 3944 KB Output is correct
13 Correct 9 ms 4128 KB Output is correct
14 Incorrect 2 ms 452 KB invalid len
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 4112 KB Output is correct
2 Correct 7 ms 4112 KB Output is correct
3 Correct 7 ms 4276 KB Output is correct
4 Correct 5 ms 3772 KB Output is correct
5 Correct 6 ms 3940 KB Output is correct
6 Correct 6 ms 3768 KB Output is correct
7 Correct 8 ms 3852 KB Output is correct
8 Correct 8 ms 3888 KB Output is correct
9 Correct 9 ms 3940 KB Output is correct
10 Correct 8 ms 4132 KB Output is correct
11 Correct 8 ms 3772 KB Output is correct
12 Correct 8 ms 3944 KB Output is correct
13 Correct 9 ms 4128 KB Output is correct
14 Incorrect 2 ms 452 KB invalid len
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 4112 KB Output is correct
2 Correct 7 ms 4112 KB Output is correct
3 Correct 7 ms 4276 KB Output is correct
4 Correct 5 ms 3772 KB Output is correct
5 Correct 6 ms 3940 KB Output is correct
6 Correct 6 ms 3768 KB Output is correct
7 Correct 8 ms 3852 KB Output is correct
8 Correct 8 ms 3888 KB Output is correct
9 Correct 9 ms 3940 KB Output is correct
10 Correct 8 ms 4132 KB Output is correct
11 Correct 8 ms 3772 KB Output is correct
12 Correct 8 ms 3944 KB Output is correct
13 Correct 9 ms 4128 KB Output is correct
14 Incorrect 2 ms 452 KB invalid len
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 4112 KB Output is correct
2 Correct 7 ms 4112 KB Output is correct
3 Correct 7 ms 4276 KB Output is correct
4 Correct 5 ms 3772 KB Output is correct
5 Correct 6 ms 3940 KB Output is correct
6 Correct 6 ms 3768 KB Output is correct
7 Correct 8 ms 3852 KB Output is correct
8 Correct 8 ms 3888 KB Output is correct
9 Correct 9 ms 3940 KB Output is correct
10 Correct 8 ms 4132 KB Output is correct
11 Correct 8 ms 3772 KB Output is correct
12 Correct 8 ms 3944 KB Output is correct
13 Correct 9 ms 4128 KB Output is correct
14 Incorrect 2 ms 452 KB invalid len
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 4112 KB Output is correct
2 Correct 7 ms 4112 KB Output is correct
3 Correct 7 ms 4276 KB Output is correct
4 Correct 5 ms 3772 KB Output is correct
5 Correct 6 ms 3940 KB Output is correct
6 Correct 6 ms 3768 KB Output is correct
7 Correct 8 ms 3852 KB Output is correct
8 Correct 8 ms 3888 KB Output is correct
9 Correct 9 ms 3940 KB Output is correct
10 Correct 8 ms 4132 KB Output is correct
11 Correct 8 ms 3772 KB Output is correct
12 Correct 8 ms 3944 KB Output is correct
13 Correct 9 ms 4128 KB Output is correct
14 Incorrect 2 ms 452 KB invalid len
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 4112 KB Output is correct
2 Correct 7 ms 4112 KB Output is correct
3 Correct 7 ms 4276 KB Output is correct
4 Correct 5 ms 3772 KB Output is correct
5 Correct 6 ms 3940 KB Output is correct
6 Correct 6 ms 3768 KB Output is correct
7 Correct 8 ms 3852 KB Output is correct
8 Correct 8 ms 3888 KB Output is correct
9 Correct 9 ms 3940 KB Output is correct
10 Correct 8 ms 4132 KB Output is correct
11 Correct 8 ms 3772 KB Output is correct
12 Correct 8 ms 3944 KB Output is correct
13 Correct 9 ms 4128 KB Output is correct
14 Incorrect 2 ms 452 KB invalid len
15 Halted 0 ms 0 KB -