회원가입
로그인
Toggle navigation
문제
문제
전체 문제
문제 출처
단계별로 풀어보기
알고리즘 분류
추가된 문제
문제 순위
문제
푼 사람이 한 명인 문제
아무도 못 푼 문제
최근 제출된 문제
최근 풀린 문제
랜덤
출처
ICPC
Olympiad
한국정보올림피아드
한국정보올림피아드시․도지역본선
전국 대학생 프로그래밍 대회 동아리 연합
대학교 대회
카카오 코드 페스티벌
Coder's High
ICPC
Regionals
World Finals
Korea Regional
Africa and the Middle East Regionals
Europe Regionals
Latin America Regionals
North America Regionals
South Pacific Regionals
문제집
대회
채점 현황
게시판
그룹
더 보기
재채점 기록
블로그
도움말
전체
공지
자유
질문
오타/오역/요청
게시판 공지
홍보
업데이트
solved.ac
글쓰기
질문 도움말
자주묻는 질문
질문 게시판에 있는 반례들 다 맞게 나오는거 같은데 어디가 문제일까요?
21608번 - 상어 초등학교
phokcks
1년 전
0
질문 게시판에 있는 반례들 다 맞게 나오는거 같은데 어디가 문제일까요?
#include <iostream> int seat_monitor(int seat[23][23], int N); int arr_monitor(int arr[20 * 20 + 1][7], int N); int love_detect(int seat[23][23], int arr[7], int x, int y); int void_detect(int seat[23][23], int x, int y); int score(int seat[23][23], int arr[20* 20+1][7], int N); int detect(int seat[23][23], int arr[20 * 20 + 1][7], int k, int N); int main() { int N; int arr[20 * 20 + 1][7] = { 0 }; int seat[23][23] = { 0 }; int max = 0, x = 2, y = 2; int count = 0; int set = 0; std::cin >> N; for (int i = 1; i <= N*N; i++) { for (int j = 1; j <= 5; j++) { std::cin >> arr[i][j]; } } for (int i = 0; i <= N; i++) { seat[0][i] = 23; seat[N+1][i] = 23; seat[i][0] = 23; seat[i][N+1] = 23; } for (int i = 1; i <= N; i++) { for (int j = 1; j <= N; j++) { count = 0; count=void_detect(seat,j, i); if ((count == 4)&&(set==0)) { seat[i][j] = arr[1][1]; set = 1; } } } for (int k = 2; k <= N * N; k++) { detect(seat,arr,k,N); } std::cout<<score(seat, arr, N); } int score(int seat[23][23], int arr[20 * 20 + 1][7], int N) { int count = 0; int score = 0; for (int i = 1; i <= N; i++) { for (int j = 1; j <= N; j++) { for (int k = 1; k <= N*N+1; k++) { if(arr[k][1]==seat[i][j]) count+=love_detect(seat, arr[k], j, i); } if (count == 1) score += 1; else if (count == 2) score += 10; else if (count == 3) score += 100; else if (count == 4) score += 1000; count = 0; } } return score; } int detect(int seat[23][23],int arr[20 * 20 + 1][7],int k, int N) { int max_love_count = 0; int love_count = 0; int void_count = 0; int max_void_count = 0; int x = 0, y = 0; int zero_x = 0, zero_y = 0; int set = 0; for (int i = N; i >= 1; i--) { for (int j = N; j >= 1; j--) { if (seat[i][j] != 0) { continue; } else { love_count = love_detect(seat, arr[k], j, i); void_count = void_detect(seat, j, i); if (max_love_count < love_count) { max_love_count = love_count; x = j; y = i; love_count = 0; max_void_count = void_count; void_count = 0; continue; } if ((max_love_count != 0) && (max_love_count == love_count)&& (max_void_count <= void_count)) { max_void_count = void_count; x = j; y = i; love_count = 0; void_count = 0; } } } } if (max_love_count > 0) { seat[y][x] = arr[k][1]; } else { for (int i = N; i >= 1; i--) { for (int j = N; j >= 1; j--) { if (seat[i][j] != 0) { continue; } else { void_count = void_detect(seat, j, i); if (max_void_count <= void_count) { max_void_count = void_count; x = j; y = i; love_count = 0; void_count = 0; } } } } if(max_void_count>0) seat[y][x] = arr[k][1]; else { for (int i = 1; i <= N; i++) { for (int j = 1; j <= N; j++) { if (set == 1) { break; } else if (seat[i][j] == 0) { seat[i][j] = arr[k][1]; set = 1; continue; } } } } } max_love_count = 0; max_void_count = 0; return 0; } int void_detect(int seat[23][23],int x,int y) { int count = 0; count = (seat[y][x + 1] == 0) + (seat[y][x - 1] == 0) + (seat[y - 1][x] == 0) + (seat[y + 1][x] == 0); return count; } int love_detect(int seat[23][23], int arr[7], int x, int y) { int count = 0; count = (seat[y][x + 1] == arr[2]) + (seat[y][x - 1] == arr[2]) + (seat[y - 1][x] == arr[2]) + (seat[y + 1][x] == arr[2]) + (seat[y][x + 1] == arr[3]) + (seat[y][x - 1] == arr[3]) + (seat[y - 1][x] == arr[3]) + (seat[y + 1][x] == arr[3]) + (seat[y][x + 1] == arr[4]) + (seat[y][x - 1] == arr[4]) + (seat[y - 1][x] == arr[4]) + (seat[y + 1][x] == arr[4]) + (seat[y][x + 1] == arr[5]) + (seat[y][x - 1] == arr[5]) + (seat[y - 1][x] == arr[5]) + (seat[y + 1][x] == arr[5]); return count; } int seat_monitor(int seat[23][23], int N) { for (int i = 0; i <= N + 1; i++) { for (int j = 0; j <= N + 1; j++) { std::cout << seat[i][j] << " "; } std::cout << "\n"; } return 0; } int arr_monitor(int arr[20 * 20 + 1][7], int N) { for (int i = 0; i <= N*N; i++) { for (int j = 0; j <= 6; j++) { std::cout << arr[i][j] << " "; } std::cout << "\n"; } return 0; }
댓글을 작성하려면
로그인
해야 합니다.
phokcks 1년 전
질문 게시판에 있는 반례들 다 맞게 나오는거 같은데 어디가 문제일까요?