알고리즘 공부
백준 점프왕 쩰리 (Small)
컴퓨터과학
2023. 7. 23. 23:44
https://www.acmicpc.net/problem/16173
16173번: 점프왕 쩰리 (Small)
쩰리는 맨 왼쪽 위의 칸에서 출발해 (행, 열)로 나타낸 좌표계로, (1, 1) -> (2, 1) -> (3, 1) -> (3, 3)으로 이동해 게임에서 승리할 수 있다.
www.acmicpc.net
쉽네용
#include <iostream>
#include <vector>
#include <queue>
#include<string>
#include<algorithm>
#include<cmath>
#include<unordered_map>
#include<map>
#include<stack>
using namespace std;
struct Point {
int i, j, t, cnt,power;
char c;
};
void Prints(vector<vector<int>>maps, int n, int m) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cout << maps[i][j]<<" ";
}
cout << endl;
}
cout << endl;
}
void Prints(vector<vector<bool>>maps, int n, int m) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cout << maps[i][j];
}
cout << endl;
}
cout << endl;
}
void Prints(vector<vector<char>>maps, int n, int m) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cout << maps[i][j];
}
cout << endl;
}
cout << endl;
}
void Prints(vector<vector<vector<char>>>maps, int n, int m, int k) {
for (int t = 0; t < k; t++) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cout << maps[t][i][j];
}
cout << endl;
}
cout << endl;
}
cout << endl;
}
void Prints(vector<vector<vector<bool>>>maps, int n, int m, int k) {
for (int t = 0; t < k; t++) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cout << maps[t][i][j];
}
cout << endl;
}
cout << endl;
}
cout << endl;
}
void Prints(string str, int n) {
for (int i = 0; i < n; i++) {
cout << str[i] << ",";
}
cout << endl;
}
struct Data {
int index;
vector<bool>bVisited;
};
struct Word {
std::string word;
int count;
};
bool compares(const Data &a, const Data &b) {
return a.index < b.index;
}
int main() {
int n;
cin >> n;
vector<vector<int>>maps;
vector<bool > tmpbVisited(n,false);
vector<vector<bool>>bVisited(n, tmpbVisited);
for (int i = 0; i < n; i++) {
vector<int>tmpMaps;
for (int j = 0; j < n; j++) {
int tmp;
cin >> tmp;
tmpMaps.push_back(tmp);
}
maps.push_back(tmpMaps);
}
queue<Point>q;
bool bEnd = false;
Point p;
p.i = 0;
p.j = 0;
p.power = maps[0][0];
q.push(p);
while (!q.empty()) {
Point start = q.front();
q.pop();
bVisited[start.i][start.j] = true;
int diri[] = {1,0};
int dirj[] = { 0,1 };
for (int i = 0; i < 2; i++) {
int tmpDiri = start.i + diri[i]*start.power;
int tmpDirj = start.j + dirj[i] * start.power;
if (tmpDiri >= n || tmpDirj >= n) {
continue;
}
if (bVisited[tmpDiri][tmpDirj]==true) {
continue;
}
if (tmpDiri == n - 1 && tmpDirj ==n -1) {
bEnd = true;
}
bVisited[tmpDiri][tmpDirj] = true;
Point tmpP;
tmpP.i = tmpDiri;
tmpP.j = tmpDirj;
tmpP.power = maps[tmpDiri][tmpDirj];
q.push(tmpP);
//Prints(bVisited, n, n);
}
}
if (bEnd == true) {
cout << "HaruHaru";
}
else {
cout << "Hing";
}
return 0;
}