회원가입
로그인
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
문제집
대회
채점 현황
랭킹
게시판
그룹
더 보기
재채점 기록
블로그
강의
실험실
도움말
BOJ Stack
BOJ Book
전체
공지
자유
질문
오타/오역/요청
게시판 공지
홍보
업데이트
solved.ac
글쓰기
질문 도움말
자주묻는 질문
도로의 개수 문제 질문 입니다.
1577번 - 도로의 개수
alohajihwan
7년 전
0
틀린 테스트 케이스를 도저히 생각하려고 해도 떠오르지 않습니다..
도와주세요ㅠㅠ
#include<stdio.h> #include<iostream> #include<vector> #include<algorithm> #include<string> #include<string.h> #include<queue> #include<stack> using namespace std; #define INF 999999999 #define ll long long int int N, M, K; ll map[102][102]; struct node { int a, b, c, d; node() {} node(int _a, int _b, int _c, int _d) : a(_a), b(_b), c(_c), d(_d) {} }arr[111]; int main() { cin >> N >> M >> K; for (int i = 0; i < K; i++) { int a, b, c, d; cin >> a >> b >> c >> d; if (c < a || d < b) { swap(a, c); swap(b, d); } arr[i] = node(a, b, c, d); } //겉부분 1로 초기화 bool ok2 = true; for (int i = 0; i <= N; i++) { for (int k = 0; k < K; k++) { node t = arr[k]; if ((t.a == i - 1 && t.b == 0) && (t.c == i && t.d == 0)) { ok2 = false; break; } } if(ok2) map[i][0] = 1; else break; } ok2 = true; for (int i = 0; i <= M; i++) { for (int k = 0; k < K; k++) { node t = arr[k]; if ((t.a == 0 && t.b == i-1) && (t.c == 0 && t.d == i)) { ok2 = false; break; } } if (ok2) map[0][i] = 1; else break; } //dp로 해결 for (int i = 1; i <= N; i++) { for (int j = 1; j <= M; j++) { bool ok = true; for (int k = 0; k < K; k++) { node t = arr[k]; if ((t.a == i - 1 && t.b == j) && (t.c == i && t.d == j)) { ok = false; map[i][j] = map[i][j-1]; } if ((t.a == i && t.b == j - 1) && (t.c == i && t.d == j)) { ok = false; map[i][j] = map[i - 1][j]; } } if(ok){ map[i][j] = map[i - 1][j] + map[i][j - 1]; } } } printf("%lld\n", map[N][M]); }
댓글을 작성하려면
로그인
해야 합니다.
alohajihwan 7년 전
틀린 테스트 케이스를 도저히 생각하려고 해도 떠오르지 않습니다..
도와주세요ㅠㅠ