Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WiP] 201902654 #1

Open
wants to merge 58 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
5f731a0
10871번 - X보다 작은 수
MGPOCKY Jul 10, 2024
810c47e
10808번 - 알파벳 개수
MGPOCKY Jul 11, 2024
3024da6
3273번 - 두 수의 합
MGPOCKY Jul 11, 2024
1a96b70
1406번 - 에디터
MGPOCKY Jul 11, 2024
197eae2
1475번 - 방 번호
MGPOCKY Jul 11, 2024
d72936f
5397번 - 키로거
MGPOCKY Jul 11, 2024
cbc37d9
1158번 - 요세푸스 문제
MGPOCKY Jul 11, 2024
af4cad2
10828번 - 스택
MGPOCKY Jul 12, 2024
292dad7
10773번 - 제로
MGPOCKY Jul 12, 2024
022654d
1874번 - 스택 수열
MGPOCKY Jul 12, 2024
6380b55
17298번 - 오큰수
MGPOCKY Jul 12, 2024
2109933
2493번 - 탑
MGPOCKY Jul 12, 2024
c2d7e61
6198번 - 옥상 정원 꾸미기
MGPOCKY Jul 12, 2024
fc4fb58
10845번 - 큐
MGPOCKY Jul 16, 2024
5d453e6
18258번 - 큐 2
MGPOCKY Jul 16, 2024
7808a8d
2164번 - 카드2
MGPOCKY Jul 16, 2024
cb145ef
10866번 - 덱
MGPOCKY Jul 16, 2024
49f45a1
1021번 - 회전하는 큐
MGPOCKY Jul 16, 2024
e8eed50
5430번 - AC
MGPOCKY Jul 16, 2024
82a638a
4949번 - 균형잡힌 세상
MGPOCKY Jul 16, 2024
e77fa8d
3986번 - 좋은 단어
MGPOCKY Jul 16, 2024
ad3f7b4
9012번 - 괄호
MGPOCKY Jul 16, 2024
ec07464
10799번 - 쇠막대기
MGPOCKY Jul 16, 2024
2cbfd9c
2504번 - 괄호의 값
MGPOCKY Jul 16, 2024
25ecee7
32068번 - 보물 찾기
MGPOCKY Jul 16, 2024
750a78d
11003번 - 최솟값 찾기
MGPOCKY Jul 17, 2024
87577ae
2577번 - 숫자의 개수
MGPOCKY Jul 17, 2024
aa21ae1
10807번 - 개수 세기
MGPOCKY Jul 17, 2024
c6f7648
1926번 - 그림
MGPOCKY Jul 17, 2024
befd64a
2178번 - 미로 탐색
MGPOCKY Jul 17, 2024
53a9076
7576번 - 토마토
MGPOCKY Jul 17, 2024
9a6c028
4179번 - 불!
MGPOCKY Jul 17, 2024
f0196b3
1697번 - 숨바꼭질
MGPOCKY Jul 18, 2024
8aea3ab
1012번 - 유기농 배추
MGPOCKY Jul 18, 2024
5999bc5
10026번 - 적록색약
MGPOCKY Jul 18, 2024
74492f2
7569번 - 토마토
MGPOCKY Jul 18, 2024
732f73f
7562번 - 나이트의 이동
MGPOCKY Jul 18, 2024
ce5b6d3
5427번 - 불
MGPOCKY Jul 18, 2024
e296cac
2583번 - 영역 구하기
MGPOCKY Jul 18, 2024
c8abd64
2667번 - 단지번호붙이기
MGPOCKY Jul 24, 2024
684a955
5014번 - 스타트링크
MGPOCKY Jul 24, 2024
e88d882
2468번 - 안전 영역
MGPOCKY Jul 24, 2024
720b2a8
6593번 - 상범 빌딩
MGPOCKY Jul 24, 2024
491b6e7
2206번 - 벽 부수고 이동하기
MGPOCKY Jul 29, 2024
9ecc888
14442번 - 벽 부수고 이동하기 2
MGPOCKY Jul 29, 2024
70e6f63
13549번 - 숨바꼭질 3
MGPOCKY Jul 29, 2024
b420738
1629번 - 곱셈
MGPOCKY Aug 5, 2024
eaea2c6
11729번 - 하노이 탑 이동 순서
MGPOCKY Aug 5, 2024
00a56f7
1074번 - Z
MGPOCKY Aug 5, 2024
62b97d4
17478번 - 재귀함수가 뭔가요?
MGPOCKY Aug 5, 2024
3e2f86a
1780번 - 종이의 개수
MGPOCKY Aug 6, 2024
6ee4d4c
2630번 - 색종이 만들기
MGPOCKY Aug 6, 2024
95edaa7
9466번 - 텀 프로젝트
MGPOCKY Aug 14, 2024
5ab33fe
2573번 - 빙산
MGPOCKY Aug 14, 2024
4d239c5
2146번 - 다리 만들기
MGPOCKY Aug 14, 2024
78b8c51
2230번 - 수 고르기
MGPOCKY Aug 20, 2024
d9daeac
1806번 - 부분합
MGPOCKY Aug 20, 2024
1a95822
1644번 - 소수의 연속합
MGPOCKY Aug 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions 201902654/10026.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#include <string>
#include <vector>
#include <iostream>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;
#define X first
#define Y second
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
char board[101][101];
bool is_visit[101][101];

int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int N;
int normal_result = 0;
int abnormal_result = 0;
queue<pair<int, int> > Q;
cin >> N;
for (int i=0;i<N;i++) {
string line;
cin >> line;
for (int j=0;j<N;j++) {
board[i][j] = line.at(j);
}
}
for (int y=0;y<N;y++) {
for (int x=0;x<N;x++) {
if (!is_visit[y][x]) {
normal_result++;
is_visit[y][x] = true;
Q.push(make_pair(x, y));
while (!Q.empty()) {
pair<int, int> top = Q.front(); Q.pop();
for (int i=0;i<4;i++) {
int nx = top.X + dx[i];
int ny = top.Y + dy[i];
if (0 <= nx && nx < N && 0 <= ny && ny < N && !is_visit[ny][nx] && board[ny][nx] == board[top.Y][top.X]) {
is_visit[ny][nx] = true;
Q.push(make_pair(nx, ny));
}
}
}
}
}
}
for (int i=0;i<N;i++) fill(is_visit[i], is_visit[i] + N, false);
for (int y=0;y<N;y++) {
for (int x=0;x<N;x++) {
if (!is_visit[y][x]) {
abnormal_result++;
is_visit[y][x] = true;
Q.push(make_pair(x, y));
while (!Q.empty()) {
pair<int, int> top = Q.front(); Q.pop();
for (int i=0;i<4;i++) {
int nx = top.X + dx[i];
int ny = top.Y + dy[i];
if (0 <= nx && nx < N && 0 <= ny && ny < N && !is_visit[ny][nx] && (board[ny][nx] == board[top.Y][top.X] || (board[ny][nx] == 'R' && board[top.Y][top.X] == 'G') || (board[ny][nx] == 'G' && board[top.Y][top.X] == 'R'))) {
is_visit[ny][nx] = true;
Q.push(make_pair(nx, ny));
}
}
}
}
}
}
cout << normal_result << ' ' << abnormal_result;
return 0;
}
59 changes: 59 additions & 0 deletions 201902654/1012.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#include <string>
#include <vector>
#include <iostream>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;
#define X first
#define Y second
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
int board[51][51];
int is_visit[51][51];

int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int T;
cin >> T;
for (int i=0;i<T;i++) {
int M, N, K;
int result = 0;
queue<pair<int, int> > Q;
cin >> M >> N >> K;
for (int y=0;y<N;y++) {
fill(board[y], board[y] + M, 0);
fill(is_visit[y], is_visit[y] + M, false);
}
for (int i=0;i<K;i++) {
int x, y;
cin >> x >> y;
board[y][x] = 1;
}
for (int y=0;y<N;y++) {
for (int x=0;x<M;x++) {
if (board[y][x] == 1 && !is_visit[y][x]) {
result++;
Q.push(make_pair(x, y));
is_visit[y][x] = true;
while (!Q.empty()) {
pair<int, int> top = Q.front(); Q.pop();
for (int i=0;i<4;i++) {
int nx = top.X + dx[i];
int ny = top.Y + dy[i];
if (0 <= nx && nx < M && 0 <= ny && ny < N && is_visit[ny][nx] == false && board[ny][nx] == 1) {
is_visit[ny][nx] = true;
Q.push(make_pair(nx, ny));
}
}
}
}
}
}
cout << result << '\n';
}

return 0;
}
61 changes: 61 additions & 0 deletions 201902654/1021.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#include <string>
#include <deque>
#include <iostream>

using namespace std;

int main() {
ios::sync_with_stdio(0);
cin.tie(0);

int N, M;
int result = 0;
deque<int> D;
cin >> N >> M;
for (int i=0;i<N;i++) {
D.push_back(i+1);
}
for (int i=0;i<M;i++) {
int value;
cin >> value;
int front_count = 0;
int back_count = 0;
while (D.front() != value) {
D.push_back(D.front());
D.pop_front();
front_count++;
}
for (int i=0;i<front_count;i++) {
D.push_front(D.back());
D.pop_back();
}
while (D.front() != value) {
D.push_front(D.back());
D.pop_back();
back_count++;
}
for (int i=0;i<back_count;i++) {
D.push_back(D.front());
D.pop_front();
}

if (front_count > back_count) {
for (int i=0;i<back_count;i++) {
D.push_front(D.back());
D.pop_back();
}
D.pop_front();
result = result + back_count;
} else {
for (int i=0;i<front_count;i++) {
D.push_back(D.front());
D.pop_front();
}
D.pop_front();
result = result + front_count;
}
}
cout << result;

return 0;
}
29 changes: 29 additions & 0 deletions 201902654/1074.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <bits/stdc++.h>

using namespace std;
#define X first
#define Y second
int order;
int N, r, c;

int record(int N, int x, int y) {
int half = pow(2, N-1);
if (N == 0) {
return 0;
}
if (x < half && y < half) return record(N-1, x, y);
if (x >= half && y < half) return half * half * 1 + record(N-1, x-half, y);
if (x < half && y >= half) return half * half * 2 + record(N-1, x, y-half);
if (x >= half && y >= half) return half * half * 3 + record(N-1, x-half, y-half);
}

int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> N >> r >> c;

cout << record(N, c, r);


return 0;
}
35 changes: 35 additions & 0 deletions 201902654/10773.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include <string>
#include <stack>
#include <iostream>

using namespace std;

int main() {
ios::sync_with_stdio(0);
cin.tie(0);

int K;
long result = 0;
stack<int> stack;
cin >> K;

for (int i=0;i<K;i++) {
int input;
cin >> input;

if (input == 0) {
stack.pop();
} else {
stack.push(input);
}
}

while (!stack.empty()) {
result = result + stack.top();
stack.pop();
}

cout << result;

return 0;
}
32 changes: 32 additions & 0 deletions 201902654/10799.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include <string>
#include <stack>
#include <iostream>

using namespace std;

int main() {
ios::sync_with_stdio(0);
cin.tie(0);

string line;
stack<char> S;
long result = 0;
cin >> line;
for (int i=0;i<line.size();i++) {
char ch = line.at(i);
if (ch == '(') {
S.push(ch);
} else {
if (line.at(i - 1) == '(') {
S.pop();
result += S.size();
} else {
S.pop();
result++;
}
}
}
cout << result;

return 0;
}
24 changes: 24 additions & 0 deletions 201902654/10807.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <string>
#include <vector>
#include <iostream>

using namespace std;

int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int N;
cin >> N;
int count[201];
fill(count, count+201, 0);
for (int i=0;i<N;i++) {
int val;
cin >> val;
count[val + 100]++;
}
int find;
cin >> find;
cout << count[find+100];

return 0;
}
20 changes: 20 additions & 0 deletions 201902654/10808.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(void) {
string s;
getline(cin, s);
vector<int> alpha(26, 0);

for (int i=0;i<s.length();++i){
int index = s[i] - 'a';
++alpha[index];
}

for (int iter : alpha) {
cout << iter << ' ';
}
}
46 changes: 46 additions & 0 deletions 201902654/10828.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include <stack>
#include <string>
#include <iostream>

using namespace std;

int main() {
ios::sync_with_stdio(0);
cin.tie(0);

int N;
stack<int> stack;
cin >> N;
for (int i=0;i<N;i++) {
string command;
cin >> command;
if (command == "push") {
int val;
cin >> val;
stack.push(val);
} else if (command == "pop") {
if (stack.empty()) {
cout << -1 << '\n';
} else {
cout << stack.top() << '\n';
stack.pop();
}
} else if (command == "size") {
cout << stack.size() << '\n';
} else if (command == "empty") {
if (stack.empty()) {
cout << 1 << '\n';
} else {
cout << 0 << '\n';
}
} else {
if (stack.empty()) {
cout << -1 << '\n';
} else {
cout << stack.top() << '\n';
}
}
}

return 0;
}
Loading