From: seantywork Date: Sat, 28 Jun 2025 11:57:01 +0000 (+0000) Subject: compete X-Git-Url: https://git.feebdaed.xyz/?a=commitdiff_plain;h=5029bf5a4740664f63e557fce8b91bb628cc570f;p=linuxyz.git compete --- diff --git a/0xetc/0xcc/compete/Makefile b/0xetc/0xcc/compete/Makefile new file mode 100644 index 0000000..12c08b8 --- /dev/null +++ b/0xetc/0xcc/compete/Makefile @@ -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 index 0000000..b09c552 --- /dev/null +++ b/0xetc/0xcc/compete/in.txt @@ -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 index 0000000..0aa3caf --- /dev/null +++ b/0xetc/0xcc/compete/main.cc @@ -0,0 +1,74 @@ +#include + + + +std::vector findMatch(std::map* m, std::vector* q){ + + std::vector 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 string_map; + std::vector 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 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 index 0000000..fa69625 --- /dev/null +++ b/0xetc/0xcc/compete/run.sh @@ -0,0 +1,4 @@ +#!/bin/bash + + +cat in.txt | ./test.out diff --git a/0xetc/0xcc/hello/src/hello.cc b/0xetc/0xcc/hello/src/hello.cc index 26f8c17..7fc38fe 100644 --- a/0xetc/0xcc/hello/src/hello.cc +++ b/0xetc/0xcc/hello/src/hello.cc @@ -62,6 +62,7 @@ std::string hello_ex::get_message(){ + int main(){ std::shared_ptr h1 = std::make_shared("im one");