Skip to content

Commit

Permalink
Merge pull request #35 from AlgoLeadMe/8-g0rnn
Browse files Browse the repository at this point in the history
8-g0rnn
  • Loading branch information
g0rnn authored Dec 10, 2024
2 parents 648645c + 3192479 commit fe9ddc7
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.DS_Store
/.vscode
1 change: 1 addition & 0 deletions g0rnn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
| 5์ฐจ์‹œ | 2024.11.01 | BFS/DFS | [์—ฐ๊ตฌ์†Œ](https://www.acmicpc.net/problem/14502) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/17 |
| 6์ฐจ์‹œ | 2024.11.06 | ๊ตฌํ˜„ | [ํ†ต๊ณ„ํ•™](https://www.acmicpc.net/problem/2108) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/23 |
| 7์ฐจ์‹œ | 2024.11.25 | ๊ตฌํ˜„ | [ํŒฐ๋ฆฐ๋“œ๋กฌ ๋งŒ๋“ค๊ธฐ](https://www.acmicpc.net/problem/1213) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/31 |
| 8์ฐจ์‹œ | 2024.11.29 | ๋ฌธ์ž์—ด | [์ž ์ˆ˜ํ•จ์‹๋ณ„](https://www.acmicpc.net/problem/2671) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/35 |

---
36 changes: 36 additions & 0 deletions g0rnn/๋ฌธ์ž์—ด/8-g0rnn-2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

bool compareLength(string a, string b) { return a.length() < b.length(); }

bool isStartWith(const string& str, const string& prefix) {
return str.compare(0, prefix.length(), prefix) == 0;
}

int main() {
int n;
cin >> n;
vector<string> prefix(n);
for (int i = 0; i < n; i++) {
cin >> prefix[i];
}

// Sort by string length
sort(prefix.begin(), prefix.end(), compareLength);

int answer = n;
for (int i = 0; i < n - 1; i++) {
for (int j = i + 1; j < n; j++) {
if (isStartWith(prefix[j], prefix[i])) {
// ์ ‘๋‘์‚ฌ๊ฐ€ ์žˆ์œผ๋ฉด i๋ฒˆ์งธ ๋‹จ์–ด๋ฅผ ์—†์•ฐ
// ์ •๋ ฌํ–ˆ์œผ๋‹ˆ ์ž์‹ ๋ณด๋‹ค ๋ฌธ์ž์—ด์ด ๊ธด๊ฒƒ๋งŒ ๋ณด๋ฉด๋จ
answer--;
break;
}
}
}
cout << answer;
return 0;
}
14 changes: 14 additions & 0 deletions g0rnn/๋ฌธ์ž์—ด/8-g0rnn.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <iostream>
#include <regex>
using namespace std;

int main() {
string sound;
cin >> sound;

if (regex_match(sound, regex("(100+1+|01)+")))
cout << "SUBMARINE\n";
else
cout << "NOISE\n";
return 0;
}

0 comments on commit fe9ddc7

Please sign in to comment.