WookjeBlog
    • 블로그
    • 소개
    • 태그
    • 수업/강의
    • 라이브러리

    Wookje blog

    알고리즘 블로그였던 것

    Featured Posts
    • [BOJ] 11899 : 괄호 끼워넣기

      11899 : 괄호 끼워넣기 풀이 왠지 그냥 짜면 돌아갈 것 같았어 코드 #include <cstdio> #include <stack> using namespace std; char s[55]; stack<char> stk; int main() { scanf("%s", s); for (int i = 0; s[i]; i++) { if (!stk.empty() && stk.top() == '(' && s[i] == ')') stk.pop(); else stk.push(s[i]); } printf("%d", stk.size()); return 0; } 아무말 백준, 백준 온라인 저지, BOJ, Baekjoon Online Judge, C, C++, 씨, 씨쁠쁠, JAVA, algorithm, 자바, 알고리즘, 자료구조, 문제, 문제...

      boj koi stack

      wookje.kwon's profile image

      wookje.kwon

      2018-08-27 20:34

    • [BOJ] 7469 : K번째 숫자

      7469 : K번째 숫자 풀이 구간합 트리를 쫌 변형해보자. 구간합 트리는 [lft, rgt] 구간에 있는 원소들의 합을 관리한다. 여기서! 원소들의 합을 원소들로 바꿔서 관리해주자! 노드를 int: 구간합이 아니라 vector: 구간의 원소들로 관리하는 거다. 구간을 실체화 시켰다고 하면 될라나? 노드가 2*n개이므로 메모리는 O(n log n)으로 충분하다! 이제 각각의 벡터에는 [lft, rgt] 구간의 원소들이 들어있게 되었고, 이제 각각의 벡터를 정렬해주자. 그리고 쿼리가 들어오면, [s, e] 구간에서 x번째 수가 무엇인지 찾아낼 것이다. 그 수를 이분탐색으로 찾아줄 건데 이건...

      boj acm-icpc index-tree

      wookje.kwon's profile image

      wookje.kwon

      2018-08-27 20:24

    • [BOJ] 15973 : 두 박스

      15973 : 두 박스 풀이 노가다를 해보자~ 사실 노가다 안 해도 됨 코드 #include <iostream> #include <string> using namespace std; int x[5], y[5]; string gogo() { if (x[0] == x[3] && y[0] == y[3] || x[1] == x[2] && y[0] == y[3] || x[0] == x[3] && y[1] == y[2] || x[1] == x[2] && y[1] == y[2]) return "POINT"; if (x[0] == x[3] && y[2] <= y[0] && y[0] <= y[3] || x[0] ==...

      boj koi naive

      wookje.kwon's profile image

      wookje.kwon

      2018-08-27 20:19

    • 제2회 천하제일 코딩대회 예선 문제 풀이

      대회 정보: https://www.acmicpc.net/contest/view/303 문제 목록: https://www.acmicpc.net/category/detail/1889 출제 및 검수 : bryan, chogahui05, exqt, jh05013, jwvg0425, pinch3773, wookje 문제 A B C D E 출제자 jwvg0425 wookje wookje wookje wookje 예선 출제에 수고해주신, 그리고 본선도 수고해주실 출제진 여러분들께 감사의 말씀 올립니다. A. 고장난 시계 풀이 15885 : 고장난 시계 흘러간 시간이 t시간일 때, 정상 시계는 t % 12를 가리키고 상대속도 x가 곱해진 시계는 t * x % 12를 가르킨다. 이를 이용해 수식을 유도하여 답을 구할 수...

      chat sunrin

      wookje.kwon's profile image

      wookje.kwon

      2018-07-13 22:07

    • [BOJ] 14971 : A Garden With Ponds

      14971 : A Garden With Ponds 풀이 코드 개더러워… 코드 #include <cstdio> #include <algorithm> #define REP(k,l,r) for(int k=(l);k<(r);k++) using namespace std; int n, m, a[12][12]; int main() { while (1) { scanf("%d %d", &n ,&m); if (!n && !m) return 0; REP(i,1,n+1) REP(j,1,m+1) scanf("%d", &a[i][j]); int res = 0; REP(i,1,n+1) REP(j,1,m+1) { REP(x,i+2,n+1) REP(y,j+2,m+1) { int mo = 1e9; REP(k,i,x+1) mo = min(mo, min(a[k][j], a[k][y])); REP(k,j,y+1) mo = min(mo, min(a[i][k], a[x][k])); int mi = -1,...

      boj acm-icpc naive

      wookje.kwon's profile image

      wookje.kwon

      2018-06-30 17:34

    • [BOJ] 14969 : Taro`s Shopping

      14969 : Taro’s Shopping 풀이 별빛이 내린다 코드 #include <cstdio> int n, m, a[1001]; int main() { while (1) { scanf("%d %d", &n, &m); if (!n && !m) { return 0; } for (int i = 0; i < n; i++) { scanf("%d", a + i); } int res = -1; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (i == j)...

      boj acm-icpc naive

      wookje.kwon's profile image

      wookje.kwon

      2018-06-30 17:33

    • [BOJ] 10531 : Golf Bot

      10531 : Golf Bot 풀이 골프 봇이 칠 수 있는 거리를 체킹 배열 a와 b에 체크했다고 생각하자. 두 배열을 bool 곱셈한 배열을 c배열이라고 하자. 만약 a[i] != 0 && b[j] != 0라면 c[i+j] != 0도 성립한다. 코드 #define _USE_MATH_DEFINES #include <cstdio> #include <cmath> #include <complex> #include <vector> #include <algorithm> using namespace std; #define sz(v) ((int)(v).size()) #define all(v) (v).begin(),(v).end() typedef complex<double> base; void fft(vector<base> &a, bool invert) { int n = sz(a); for (int i=1,j=0;i<n;i++){ int...

      boj acm-icpc fast-fourier-transform math

      wookje.kwon's profile image

      wookje.kwon

      2018-06-30 15:59

    • [BOJ] 1067 : 이동

      1067 : 이동 풀이 . 코드 #define _USE_MATH_DEFINES #include <cstdio> #include <cmath> #include <complex> #include <vector> #include <algorithm> using namespace std; #define sz(v) ((int)(v).size()) #define all(v) (v).begin(),(v).end() typedef complex<double> base; void fft(vector<base> &a, bool invert) { int n = sz(a); for (int i=1,j=0;i<n;i++){ int bit = n >> 1; for (;j>=bit;bit>>=1) j -= bit; j += bit; if (i < j) swap(a[i],a[j]); } for (int len=2;len<=n;len<<=1){ double ang = 2*M_PI/len*(invert?-1:1); base wlen(cos(ang),sin(ang)); for (int i=0;i<n;i+=len){...

      boj fast-fourier-transform

      wookje.kwon's profile image

      wookje.kwon

      2018-06-30 09:21

    • [BOJ] 1074 : Z

      1074 : Z 풀이 약간의 커팅이 필요하다. 코드 #include <cstdio> #include <cstdlib> int n, r, c; void f(int x, int y, int s, int cnt) { if (s == 0 && x == r && y == c) { printf("%d\n", cnt); exit(0); } if (r < x || c < y || x + s*2 <= r || y + s*2 <= c) return; int nx = x + s, ny = y + s,...

      boj divide-and-conquer

      wookje.kwon's profile image

      wookje.kwon

      2018-06-24 22:17

    • [BOJ] 10451 : 순열 사이클

      10451 : 순열 사이클 풀이 . 코드 #include <iostream> #include <vector> #include <algorithm> #include <cstring> using namespace std; int t, n; vector<int> a[1001]; int ans, chk[1001]; void dfs(int now) { chk[now] = 1; for (int i = 0; i < a[now].size(); i++) if (chk[a[now][i]] != 1) dfs(a[now][i]); } int main() { cin >> t; while (t--) { cin >> n; for (int i = 1; i <= n; i++) { int v; cin >> v;...

      boj graph dfs

      wookje.kwon's profile image

      wookje.kwon

      2018-06-24 22:15

    • Previous Page
    • 13
    • 14
    • 15
    • 16
    • 17
    • Next Page
    • github
    • facebook
    • rss

    Copyright © Wookje Kwon. All rights reserved.