목록전체 글 (370)
cgy12306
// https://www.acmicpc.net/problem/1219 // 오민식의 고민 #include #include #include #include using namespace std; int N, M, from, to, INF = -999999999; long long minCost[51]; int map[51]; bool visited[51], Geecheck[51]; bool check = false; vector Edge; void bellman(int start) { fill(minCost, minCost + N + 1, INF); minCost[start] = map[start]; for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) {..
// https://www.acmicpc.net/problem/1865 // 웜홀 #include #include #include using namespace std; int T, N, M, W; vector Edge; long long minCost[502]; int INF = 999999999; bool bellman(int start) { fill(minCost, minCost + N + 1, INF); minCost[start] = 0; for (int i = 0; i < N; i++) { for (int j = 1; j nextCost) { minCost[next] = nextCost; if (i == N - 1) return true; } } } } return false; } int main..
// https://www.acmicpc.net/problem/11657 // 타임머신 #include #include #include #include using namespace std; int N, M; vector Edge; long long minCost[502]; int INF = 999999999; bool bellman_ford(int start) { fill(minCost, minCost + N + 1, INF); minCost[start] = 0; for (int i = 0; i < N; i++) { for (int j = 1; j nextCost) { minCost[next] = nextCost; if (i == N - 1) return true; } } } } return false;..
// https://www.acmicpc.net/problem/1956 // 운동 #include #include #include using namespace std; int map[402][402]; int V, E; int INF = 999999999; void floyd() { for(int k = 1; k > E; for (int i = 0; i > from >> to >> cost; map[from][to] = cost; } floyd(); int Min = INF; for (int i = 1; i
// https://www.acmicpc.net/problem/10159 // 저울 #include using namespace std; int N, M; bool map[102][102]; void floyd() { for (int k = 1; k > M; for (int i = 0; i > from >> to; map[from][to] = true; } floyd(); int cnt = 0; for (int i = 1; i
// https://www.acmicpc.net/problem/1261 // 알고스팟 #include #include #include #include #include #include using namespace std; int N, M, INF = 999999999; int map[102][102], minCost[102][102]; int dx[] = { -1, 1, 0, 0 }; int dy[] = { 0, 0, -1, 1 }; void dijkstra() { fill(minCost[0], minCost[102], INF); priority_queue pq; minCost[1][1] = 0; pq.push(make_tuple(map[1][1], 1, 1)); while (!pq.empty()) { i..
// https://www.acmicpc.net/problem/4485 // 녹색 옷 입은 애가 젤다지? #include #include #include #include #include using namespace std; int N, map[126][126], INF = 999999999, minCost[126][126]; int dx[] = { -1, 1, 0 ,0 }; int dy[] = { 0, 0, -1, 1 }; bool visited[126][126]; void dijkstra(int x, int y) { fill(minCost[0], minCost[126], INF); priority_queue pq; minCost[x][y] = map[x][y]; pq.push(make_tuple(-ma..

SRP SRP(Single reponsibility principle, 단일 책임 원칙) : 한 클래스는 하나의 책임만 가져야 한다. SRP 위배되는 예 class 사람 { final static Boolean 남성 = true; final static Boolean 여성 = false; boolean 성별; void 군대(){ if(this.성별 == 남성) { // 군대를 간다 } else{ // 군대를 가지 않는다. } } } SRP 원칙 위배하지 않는 경우 abstract class 사람 { abstract void 군대(); } class 남성 extends 사람{ void 군대(){ // 군대를 간다. } } class 여성 extends 사람{ void 군대(){ // 군대를 가지 않는다. ..

객체 지향의 4대 특성 캡슐화(Encapsulation) : 정보 은닉 상속(Inheritance): 재사용 추상화(Abstraction) : 구체적인 것을 분해해서 관심 영역(애플리케이션 경계)에 있는 특성만을 가지고 재조합 하는 것 = 모델링 다형성(Polymorphism) : 사용 편의 객체 : 유일무이한 사물 클래스 : 같은 특성을 지닌 여러 객체를 총칭하는 집합. 객체지향의 핵심 : IoC(Inversion of Control)을 통해 상위 레벨의 모듈을 하위 레벨의 모듈로부터 보호하는 것. 인스턴스 : 클래스의 정의를 통해 만들어진 객체. 객체가 메모리에 할당되어 실제 사용될 때를 인스턴스라고 함. class test{ Mouse micky; // Mouse 타입의 객체 micky = new ..

JDK : Java Development Kit / 자바 개발 도구 (ex. 소프트웨어 개발 도구) JRE : Java Runtime Environment / 자바 실행 환경 (ex. 운영체제) JVM : Java Virtual Machine / 자바 가상 기계 (ex. 컴퓨터 하드웨어) 자바 실행 원리 JRE는 프로그램 안에 main() 메소드가 있는지 확인. main() 메소드의 존재가 확인되면 JVM은 java.lang 패키지를 스태틱 영역에 가져다 놓음. JVM이 맨 먼저하는 일을 전처리 과정이라고 함. 그 다음 JVM은 개발자가 작성한 모든 클래스와 임포트 패키지를 스태틱 영역에 가져다 놓는다. 객체 멤버 변수는 heap영역에, 지역 변수들은 stack 영역에 있다. main 메소드 스택 프레임..