ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 백준 - 전광판의 숫자 [16159]
    공부/baekjoon 문제 2019. 6. 19. 14:38

     * 해당 코드의 결과는 "출력초과" 입니다. 아직 해결하지 못한코드이니 참고만 해주시길 바랍니다.

     

    #include <iostream>
    #include <vector>
    #include <algorithm>
    #include <cstring>
    using namespace std;
    
    char numbers[7][60];
    char arr[7][60];
    vector<int> num_list;
    
    int get_num(int n, int i) {
    	int sq = 0;
    	int num = 0;
    
    	if (n == 10)	num = 0;
    
    	else if (n == 6)	num = 1;
    	else if (n == 14)	num = 2;
    	else if (n == 9)	num = 3;
    	else if (n == 11)	num = 4;
    	else if (n == 13)	num = 5;
    	else if (n == 12)	num = 6;
    	else if (n == 8)	num = 7;
    	else if (n == 16)	num = 8;
    	else if (n == 15)	num = 9;
    
    	for (int j = 0; j < 7; j++) {
    		for (int k = num * 6; k < num * 6 + 6; k++) {
    			numbers[j][k] = arr[j][i * 6 + sq];
    			sq++;
    		}
    		sq = 0;
    	}
    	return num;
    }
    
    void set_num(vector<int> num_list) {
    	int sq = 0;
    	for (int i = 0; i < (int)num_list.size(); i++) {
    		int current = num_list[i];
    		for (int j = 0; j < 7; j++) {
    			for (int k = i * 6; k < i * 6 + 6; k++) {
    				arr[j][k] = numbers[j][current * 6 + sq];
    				sq++;
    			}
    			sq = 0;
    		}
    	}
    }
    
    int main() {
    	int num_num;
    	int num_check = 0;
    
    	for (int i = 0; i < 7; i++) {
    		for (int j = 0; j < 60; j++)
    			numbers[i][j] = '0';
    	}
    	for (int i = 0; i < 7; i++) {
    		cin >> arr[i];
    	}
    	num_num = strlen(arr[1]) / 6;
    
    
    	for (int i = 0; i < num_num; i++) {
    		for (int j = 0; j < 7; j++)
    			for (int k = i * 6; k < i * 6 + 6; k++) {
    				if (arr[j][k] == '1')
    					num_check++;
    			}
    		num_list.push_back(get_num(num_check, i));
    		num_check = 0;
    	}
    
    	if (!next_permutation(num_list.begin(), num_list.end())) {
    		cout << "The End";
    		return 0;
    	}
    
    	set_num(num_list);
    
    	for (int i = 0; i < 7; i++) {
    		for (int j = 0; j < 6 * num_num; j++)
    			cout << arr[i][j];
    		if (i != 6)
    			cout << endl;
    	}
    
    
    	return 0;
    }
    

    '공부 > baekjoon 문제' 카테고리의 다른 글

    백준 - 빗물 [14719]  (0) 2019.06.21
    백준 - 색종이 붙이기 [17136]  (0) 2019.06.19
    백준 - 연구소 3 [17142]  (0) 2019.06.13
    백준 - 캐슬 디펜스 [17135]  (0) 2019.06.13
    백준 - 파이프 옮기기 1 [17070]  (0) 2019.06.13

    댓글

Designed by Tistory.