Skip to content

Commit

Permalink
feat: add 5052 9935
Browse files Browse the repository at this point in the history
  • Loading branch information
owl1753 committed Aug 7, 2024
1 parent 4ad4eae commit 51ba1c7
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
34 changes: 34 additions & 0 deletions NCPC 2007/5052.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include <iostream>
#include <set>
#include <vector>
using namespace std;

int main() {
int t;
cin >> t;
while (t--) {
set<string> s;
vector<string> v;
bool result = true;
int n;
cin >> n;
for (int i = 0; i < n; i++) {
string tmp;
cin >> tmp;
s.insert(tmp);
v.push_back(tmp);
}
for (int i = 0; i < n; i++) {
string tmp = "";
for (int j = 0; j < v[i].size() - 1; j++) {
tmp += v[i][j];
if (s.find(tmp) != s.end()) result = false;
}
}
if (result) {
cout << "YES" << "\n";
} else {
cout << "NO" << "\n";
}
}
}
29 changes: 29 additions & 0 deletions coci1314-5/9935.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main() {
vector<char> stack;
string str, bomb;
cin >> str;
cin >> bomb;
for (int i = 0; i < str.size(); i++) {
stack.push_back(str[i]);
if (stack.size() < bomb.size()) continue;
bool flag = true;
for (int j = 0; j < bomb.size(); j++) {
if (stack[stack.size() - bomb.size() + j] != bomb[j]) flag = false;
}
if (flag) {
for (int j = 0; j < bomb.size(); j++) stack.pop_back();
}
}
if (stack.empty()) {
cout << "FRULA";
} else {
for (int i = 0; i < stack.size(); i++) {
cout << stack[i];
}
}
}

0 comments on commit 51ba1c7

Please sign in to comment.