Algorithm/BOJ
-
알파벳 - 1987Algorithm/BOJ 2020. 3. 29. 16:41
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 //1987 - 알파벳 #include using namespace std; int N, M; char arr[20][20]; bool alph[26]; int xarr[4] = {0, 0, 1, -1}; int yarr[4] = {1, -1, 0, 0}; void init() { cin >> N >> M; string s; for (int i = 0; i > s; for (int j = 0; j
-
N-Queen - 9663Algorithm/BOJ 2020. 3. 29. 16:17
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 //9663 - N-Queen #include using namespace std; int N; bool r[15], c[15], dc[29], ic[29]; int di(int x, int y) { return x - y + N-1; } int ii(int x, int y) { return x+y; } int ch(int x, int y, int n) { if(n == N-1) return 1; if(x == N) return 0; r[x] = c[y] = dc[di(x, y)] = ic[i..
-
캔디 분배 - 3955Algorithm/BOJ 2020. 3. 24. 16:25
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 //3955 - 캔디 분배 #include using namespace std; #define MOD 1000000001 int N, K; pair EEA(int a, int b) { long long old_r, r, temp_r; long long old_s, s, temp_s; long long old_t, t, temp_t; long long q; old..
-
이항 계수 3 - 11401Algorithm/BOJ 2020. 3. 24. 00:21
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 //이항 계수 3 - 11401 #include using namespace std; int N, K; long long ans; const long long MOD = 1000000007; long long revM(int a) { long long old_r, r, temp_r; long long old_s, s, temp_s; long long old_t, t, temp_t; long long q; old_r = a, r = MOD; old_s = 1, s = ..
-
단어 암기 - 18119Algorithm/BOJ 2020. 3. 23. 11:55
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 //18119 - 단어암기 #include using namespace std; int N, M; int count[10000]; int full[10000]; int bucket[10000][26]; void init() { cin >> N >> M; for(int i = 0; i c; if (flag == 1) { for (int j = 0; j 0) { bucket[j][c-'..
-
ACM Craft - 1005Algorithm/BOJ 2020. 3. 22. 03:07
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 //1005 - ACM Craft #include #include using namespace std; int N, K; vector adj; int cost[1001]; int S; int cache[1001]; void init() { cin >> N >> K; for(int i = 1; i cost[i]; int x, y; for(int i = 0; i> x >> y; adj[y].push_back(x); } cin >> S; } in..
-
YouTube - 3117Algorithm/BOJ 2020. 3. 20. 04:26
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 //3117 - youtube #include using namespace std; int N, K, M; int arr[100001][31]; int student[100001]; void init() { cin >> N >> K >> M; for (int i = 0; i > student[i]; for (int i = 1; i > arr[i][0]; for (int j = 1; j