본문 바로가기

반응형

코딩 이야기/백준 풀이

(51)
백준 1926번: 그림 C++코드(BFS) #include #include #include #include #include using namespace std; int n,m; int picture[501][501]; int visit[501][501] = {0,}; int x[4] = {0,0,1,-1}; int y[4] = {1,-1,0,0}; int bfs(int s1, int s2){ int funcnt = 0; queue q; q.push(make_pair(s1,s2)); while(!q.empty()){ funcnt += 1; pair now = q.front(); q.pop(); for(int i=0; i> m; vector v; v.push_back(0); for(int i=0; i picture[i][j]; } } for(int ..
백준 2193번: 이친구 C++코드(DP, 다이나믹 프로그래밍) #include using namespace std; long long arr[100] = {0,}; long long dp(int n){ if(n n; arr[1] = 1; arr[2] = 1; cout
백준 1181번: 단어 정렬 C++코드(정렬) #include #include #include #include #include using namespace std; bool cmp(const string & a, const string & b){ if(a.length() < b.length()) return true; else if(a.length() == b.length()){ if(a < b) return true; } return false; } int main(){ int n; char temp[51]; vector words; scanf("%d", &n); for(int i=0; i
백준 3046번: R2 C언어 코드(구현, 사칙연산) #include int main(){ int r1, s; scanf("%d %d", &r1, &s); printf("%d", s+(s-r1)); } 설명 S가 평균이므로 S에 S와 R1의 차이만큼 더해주면 R2가 나온다. 문제점 없다.
백준 1932번: 정수 삼각형 C++코드(DP, 다이나믹 프로그래밍) #include #include using namespace std; int arr[501][501]; int cost[501][501] = {0,}; int n; void dp(){ for(int i=0; i
백준 11758번: CCW C++코드(기하학) #include using namespace std; int just(int x1, int x2, int x3, int y1, int y2, int y3){ int temp = (x2-x1)*(y3-y1) - (y2-y1)*(x3-x1); temp = temp/2; if(temp > 0){ return 1; }else if(temp == 0){ return 0; }else if(temp > x1 >> y1 >> x2 >> y2 >> x3 >> y3; cout
백준 11650번: 좌표 정렬하기 C++코드(정렬) #include #include #include #include using namespace std; int main(){ int n; int temp, temp2; vector arr; scanf("%d", &n); for(int i=0; i
백준 2217번: 로프 C++코드(정렬, 그리디 알고리즘) #include #include using namespace std; int main(){ int n; int temp; int rope[100001]; int min = 0; scanf("%d", &n); for(int i=0; i

반응형