diff --git a/1316.cpp b/1316.cpp new file mode 100644 index 0000000..c3ff938 --- /dev/null +++ b/1316.cpp @@ -0,0 +1,42 @@ +#include +#include +#include +using namespace std; + +bool wordchecker(string s) { + vector check(26, false); + char temp; + + for (int i = 0; i < s.length(); i++) { + if (check[s[i] - 'a'] == false) { + check[s[i] - 'a'] = true; + } + else { + if (temp != s[i]) { + return false; + } + } + temp = s[i]; + } + return true; +} + +int main() { + vector check(26, false); + int n; + cin >> n; + + int count = 0; + + for (int i = 0; i < n; i++) { + string s; + cin >> s; + if (wordchecker(s) == true) { + count++; + } + } + + cout << count; + + return 0; +} \ No newline at end of file diff --git a/2840.cpp b/2840.cpp new file mode 100644 index 0000000..a8745b9 --- /dev/null +++ b/2840.cpp @@ -0,0 +1,53 @@ +#include +#include +using namespace std; + +string getWheel(int n, int k) { + vector wheel(n, '?'); + vector check(26, false); + + int point = 0; + + for (int i = 0; i < k; i++) { + int cnt; + char letter; + cin >> cnt >> letter; + cnt %= n; + point -= cnt; + if (point < 0) { + point += n; + } + if (wheel[point] != '?' && wheel[point] != letter) { + return "!"; + } + else + wheel[point] = letter; + } + + for (int i = 0; i < wheel.size(); i++) { + if (wheel[i] == '?') + continue; + if (check[wheel[i] - 'A'] == false) { + check[wheel[i] - 'A'] = true; + } + else + return "!"; + } + + string answer = ""; + + for (int i = 0; i < wheel.size(); i++) { + + answer += wheel[(i + point)%n]; + } + return answer; +} + +int main() { + int n, k; + cin >> n >> k; + + cout << getWheel(n, k); + + return 0; +} \ No newline at end of file diff --git a/5397.cpp b/5397.cpp new file mode 100644 index 0000000..5e4a971 --- /dev/null +++ b/5397.cpp @@ -0,0 +1,72 @@ +#include +#include +#include +using namespace std; + +string getPassword(string s) { + + stack front; + stack back; + + while (!front.empty()) { + front.pop(); + } + while (!back.empty()) { + back.pop(); + } + + for (int i = 0; i < s.length(); i++) { + if (s[i] == '<') { + if (!front.empty()) { + back.push(front.top()); + front.pop(); + } + } + + else if (s[i] == '>') { + if (!back.empty()) { + front.push(back.top()); + back.pop(); + } + } + + else if (s[i] == '-') { + if (!front.empty()) { + front.pop(); + } + } + + else { + // ¿µ¹®ÀÚ ÀÔ·Â + front.push(s[i]); + } + } + + while (!front.empty()) { + back.push(front.top()); + front.pop(); + } + + string password; + + while (!back.empty()) { + password += back.top(); + back.pop(); + } + + return password; +} + +int main() { + int n; + cin >> n; + + while (n--) { + string s; + cin >> s; + cout << getPassword(s) << '\n'; + } + + + return 0; +} \ No newline at end of file diff --git a/8911.cpp b/8911.cpp new file mode 100644 index 0000000..5337a9e --- /dev/null +++ b/8911.cpp @@ -0,0 +1,56 @@ +#include +#include +#include +using namespace std; + +int getSize(string s) { + int top = 0, bottom = 0, left = 0, right = 0; + int dir = 0; // ¹æÇâ + vector point(4, 0); // ºÏ µ¿ ³² ¼­ ½Ã°è¹æÇâ + + for (int i = 0; i < s.length(); i++) { + if (s[i] == 'F') { + point[dir % 4]++; + point[(dir + 2) % 4]--; + } + else if (s[i] == 'B') { + point[dir % 4]--; + point[(dir + 2) % 4]++; + } + else if (s[i] == 'L') { + dir += 3; + } + else if (s[i] == 'R') { + dir++; + } + + if (point[0] > top) { + top = point[0]; + } + if (point[1] > right) { + right = point[1]; + } + if (point[2] > bottom) { + bottom = point[2]; + } + if (point[3] > left) { + left = point[3]; + } + } + + int size = (top + bottom) * (right + left); + return size; +} + +int main() { + int n; + cin >> n; + + for (int i = 0; i < n; i++) { + string s; + cin >> s; + cout << getSize(s) << '\n'; + } + + return 0; +} \ No newline at end of file