]> git.feebdaed.xyz Git - linuxyz.git/commitdiff
compete
authorseantywork <seantywork@gmail.com>
Sat, 28 Jun 2025 11:57:01 +0000 (11:57 +0000)
committerseantywork <seantywork@gmail.com>
Sat, 28 Jun 2025 11:57:01 +0000 (11:57 +0000)
0xetc/0xcc/compete/Makefile [new file with mode: 0644]
0xetc/0xcc/compete/in.txt [new file with mode: 0644]
0xetc/0xcc/compete/main.cc [new file with mode: 0644]
0xetc/0xcc/compete/run.sh [new file with mode: 0755]
0xetc/0xcc/hello/src/hello.cc

diff --git a/0xetc/0xcc/compete/Makefile b/0xetc/0xcc/compete/Makefile
new file mode 100644 (file)
index 0000000..12c08b8
--- /dev/null
@@ -0,0 +1,8 @@
+all:
+
+       g++ -std=c++14 -o test.out main.cc
+
+
+clean:
+
+       rm -rf *.o *.out
\ No newline at end of file
diff --git a/0xetc/0xcc/compete/in.txt b/0xetc/0xcc/compete/in.txt
new file mode 100644 (file)
index 0000000..b09c552
--- /dev/null
@@ -0,0 +1,20 @@
+13
+abcde
+sdaklfj
+asdjf
+na
+basdn
+sdaklfj
+asdjf
+na
+asdjf
+na
+basdn
+sdaklfj
+asdjf
+5
+abcde
+sdaklfj
+asdjf
+na
+basdn
diff --git a/0xetc/0xcc/compete/main.cc b/0xetc/0xcc/compete/main.cc
new file mode 100644 (file)
index 0000000..0aa3caf
--- /dev/null
@@ -0,0 +1,74 @@
+#include <bits/stdc++.h>
+
+
+
+std::vector<int> findMatch(std::map<std::string, int>* m, std::vector<std::string>* q){
+
+    std::vector<int> res;
+
+    std::string thisq;
+
+    for(int i = 0 ; i < q->size(); i++){
+
+        thisq = (*q)[i];
+
+        if (m->find(thisq) == m->end()) {
+            res.push_back(0);
+        } else {
+            res.push_back((*m)[thisq]);
+        }
+
+    }
+    
+    return res;
+}
+
+
+
+int main(){
+    
+    
+    int list_count = 0;
+    int query_count = 0;
+    std::map<std::string, int> string_map;
+    std::vector<std::string> queries;
+
+    std::string tmp;
+
+    std::getline(std::cin, tmp);
+
+    list_count = std::stoi(tmp);
+
+    for(int i = 0 ; i < list_count; i++){
+        std::string item;
+        std::getline(std::cin, item);
+
+        if (string_map.find(item) == string_map.end()) {
+            string_map[item] = 1;
+        } else {
+            string_map[item] += 1;
+        }
+    }
+
+    std::getline(std::cin, tmp);
+
+    query_count = std::stoi(tmp);
+
+    for(int i = 0; i < query_count; i++){
+        std::string item;
+        std::getline(std::cin, item);
+        queries.push_back(item);
+
+    }
+
+    std::vector<int> ans = findMatch(&string_map, &queries);
+
+    for(int i = 0; i < ans.size(); i++){
+
+        std::cout << ans[i] << std::endl;
+
+    }
+
+
+    return 0;
+}
\ No newline at end of file
diff --git a/0xetc/0xcc/compete/run.sh b/0xetc/0xcc/compete/run.sh
new file mode 100755 (executable)
index 0000000..fa69625
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/bash 
+
+
+cat in.txt | ./test.out
index 26f8c17359de4eaa4d15e71fa1fcd19ccc35b0ca..7fc38fe081b4264a4636a12d26c4457bcff7017d 100644 (file)
@@ -62,6 +62,7 @@ std::string hello_ex::get_message(){
 
 
 
+
 int main(){
 
     std::shared_ptr<hello> h1 = std::make_shared<hello>("im one");