From 7eaf59bb455b17b9eae3daa807dd6df033dd0dd0 Mon Sep 17 00:00:00 2001 From: Philippe Zwietering Date: Tue, 2 Nov 2021 12:54:37 +0100 Subject: [PATCH] Changed the folder structure of codeforces problemsets --- codeforces/problemsets/chatroom/a.cpp | 32 +++++++++++ codeforces/problemsets/football/football.cpp | 39 +++++++++++++ codeforces/problemsets/hq9+/a.cpp | 28 ++++++++++ codeforces/problemsets/interestingDrink/a.cpp | 55 +++++++++++++++++++ .../problemsets/puzzlePieces/puzzlePieces.cpp | 37 +++++++++++++ codeforces/problemsets/stringTask/a.cpp | 30 ++++++++++ codeforces/problemsets/taxi/a.cpp | 47 ++++++++++++++++ codeforces/problemsets/team/team.cpp | 32 +++++++++++ codeforces/problemsets/theatreSquare/a.cpp | 21 +++++++ codeforces/problemsets/twins/twins.cpp | 39 +++++++++++++ .../problemsets/watermelon/watermelon.cpp | 24 ++++++++ .../wayTooLongWords/wayTooLongWords.cpp | 35 ++++++++++++ codeforces/problemsets/youngPhysicist/a.cpp | 29 ++++++++++ 13 files changed, 448 insertions(+) create mode 100644 codeforces/problemsets/chatroom/a.cpp create mode 100644 codeforces/problemsets/football/football.cpp create mode 100644 codeforces/problemsets/hq9+/a.cpp create mode 100644 codeforces/problemsets/interestingDrink/a.cpp create mode 100644 codeforces/problemsets/puzzlePieces/puzzlePieces.cpp create mode 100644 codeforces/problemsets/stringTask/a.cpp create mode 100644 codeforces/problemsets/taxi/a.cpp create mode 100644 codeforces/problemsets/team/team.cpp create mode 100644 codeforces/problemsets/theatreSquare/a.cpp create mode 100644 codeforces/problemsets/twins/twins.cpp create mode 100644 codeforces/problemsets/watermelon/watermelon.cpp create mode 100644 codeforces/problemsets/wayTooLongWords/wayTooLongWords.cpp create mode 100644 codeforces/problemsets/youngPhysicist/a.cpp diff --git a/codeforces/problemsets/chatroom/a.cpp b/codeforces/problemsets/chatroom/a.cpp new file mode 100644 index 0000000..b3ffcd4 --- /dev/null +++ b/codeforces/problemsets/chatroom/a.cpp @@ -0,0 +1,32 @@ +#include + +using namespace std; + +int main(){ + ios::sync_with_stdio(0); + cin.tie(0); + + string s; + cin >> s; + + string hello = "olleh"; + + for(char& c : s){ + if(c == hello.back()){ + hello.pop_back(); + } + if(hello.empty()){ + break; + } + } + + if(hello.empty()){ + cout << "YES"; + } else{ + cout << "NO"; + } + + cout << flush; + + return 0; +} diff --git a/codeforces/problemsets/football/football.cpp b/codeforces/problemsets/football/football.cpp new file mode 100644 index 0000000..3098a82 --- /dev/null +++ b/codeforces/problemsets/football/football.cpp @@ -0,0 +1,39 @@ +#include + +using namespace std; + + +int main(){ + ios::sync_with_stdio(0); + cin.tie(0); + + string s; + getline(cin, s); + int n = 0, m = 0; + + bool no = true; + + for(auto c : s){ + if(c == '0'){ + n++; + m = 0; + } else{ + m++; + n = 0; + } + + if(abs(n - m) > 6){ + cout << "YES"; + no = false; + break; + } + } + + if(no){ + cout << "NO"; + } + + cout << flush; + + return 0; +} \ No newline at end of file diff --git a/codeforces/problemsets/hq9+/a.cpp b/codeforces/problemsets/hq9+/a.cpp new file mode 100644 index 0000000..ca0afa0 --- /dev/null +++ b/codeforces/problemsets/hq9+/a.cpp @@ -0,0 +1,28 @@ +#include + +using namespace std; + + +int main(){ + ios::sync_with_stdio(0); + cin.tie(0); + + string s; + getline(cin, s); + bool no = true; + for(char& c : s){ + if(c == 'H' || c == 'Q' || c == '9'){ + cout << "YES"; + no = false; + break; + } + } + + if(no){ + cout << "NO"; + } + + cout << flush; + + return 0; +} \ No newline at end of file diff --git a/codeforces/problemsets/interestingDrink/a.cpp b/codeforces/problemsets/interestingDrink/a.cpp new file mode 100644 index 0000000..67af870 --- /dev/null +++ b/codeforces/problemsets/interestingDrink/a.cpp @@ -0,0 +1,55 @@ +#include + +using namespace std; + +int main(){ + ios::sync_with_stdio(0); + cin.tie(0); + + int n, q, xi, mi; + cin >> n; + + vector xs; + xs.reserve(n); + + for(int i = 0; i < n; ++i){ + cin >> xi; + xs.push_back(xi); + } + sort(xs.begin(), xs.end()); + + cin >> q; + for(int qi = 0; qi < q; ++qi){ + cin >> mi; + + if(mi >= xs.back()){ + cout << n << "\n"; + continue; + } + if(mi < xs.front()){ + cout << "0\n"; + continue; + } + + int start = 0, end = n - 1; + int middle = (end + start) / 2; + + while(middle != start && middle != end){ + if(mi > xs[middle]){ + start = middle + 1; + } else{ + end = middle; + } + middle = (end + start) / 2; + } + if(mi < xs[middle]){ + cout << middle << "\n"; + } else{ + cout << middle + 1 << "\n"; + } + } + + cout << flush; + + return 0; +} diff --git a/codeforces/problemsets/puzzlePieces/puzzlePieces.cpp b/codeforces/problemsets/puzzlePieces/puzzlePieces.cpp new file mode 100644 index 0000000..527beb0 --- /dev/null +++ b/codeforces/problemsets/puzzlePieces/puzzlePieces.cpp @@ -0,0 +1,37 @@ +#include +#include +#include +#include + +using namespace std; + +void test_case(int tc){ + int n, m; + cin >> n >> m; + + if(n < 2 || m < 2){ + cout << "YES\n"; + } else if(n == 2 && m == 2){ + cout << "YES\n"; + } else{ + cout << "NO\n"; + } +} + + + +int main(){ + ios::sync_with_stdio(0); + cin.tie(0); + + int t; + cin >> t; + + for(int tc = 1; tc <= t; ++tc){ + test_case(tc); + } + + cout << flush; + + return 0; +} \ No newline at end of file diff --git a/codeforces/problemsets/stringTask/a.cpp b/codeforces/problemsets/stringTask/a.cpp new file mode 100644 index 0000000..8febbc3 --- /dev/null +++ b/codeforces/problemsets/stringTask/a.cpp @@ -0,0 +1,30 @@ +#include + +using namespace std; + + +int main(){ + ios::sync_with_stdio(0); + cin.tie(0); + + string s, result = ""; + + getline(cin, s); + for(char& c : s){ + if(c >= 'A' && c <= 'Z'){ + c += 32; + } + if(c == 'a' || c == 'e' || c == 'o' || c == 'i' || c == 'u' || c == 'y'){ + continue; + } else{ + result += "."; + result += c; + } + } + + cout << result; + + cout << flush; + + return 0; +} diff --git a/codeforces/problemsets/taxi/a.cpp b/codeforces/problemsets/taxi/a.cpp new file mode 100644 index 0000000..437ba9a --- /dev/null +++ b/codeforces/problemsets/taxi/a.cpp @@ -0,0 +1,47 @@ +#include + +using namespace std; + +int main(){ + ios::sync_with_stdio(0); + cin.tie(0); + + int n, a, result = 0, ones = 0, twos = 0, threes = 0; + cin >> n; + + for(int i = 0; i < n; i++){ + cin >> a; + if(a != 4){ + if(a == 1){ + ones++; + } else if(a == 2){ + twos++; + } else{ + threes++; + } + } else{ + result++; + } + } + + int onethreegroups = min(ones, threes); + result += threes; + ones -= onethreegroups; + + int doubletwos = twos / 2; + result += doubletwos; + twos -= doubletwos * 2; + + if(twos == 1){ + result++; + ones -= min(2, ones); + } + + result += ceil((float)ones / 4); + + cout << result; + + cout << flush; + + return 0; +} diff --git a/codeforces/problemsets/team/team.cpp b/codeforces/problemsets/team/team.cpp new file mode 100644 index 0000000..517f0f1 --- /dev/null +++ b/codeforces/problemsets/team/team.cpp @@ -0,0 +1,32 @@ +#include +#include +#include +#include + +using namespace std; + + +int main(){ + ios::sync_with_stdio(0); + cin.tie(0); + + int t; + cin >> t; + + int n = 0; + + for(int tc = 1; tc <= t; ++tc){ + int a, b, c; + cin >> a >> b >> c; + + if(a + b + c > 1){ + n++; + } + } + + cout << n; + + cout << flush; + + return 0; +} \ No newline at end of file diff --git a/codeforces/problemsets/theatreSquare/a.cpp b/codeforces/problemsets/theatreSquare/a.cpp new file mode 100644 index 0000000..e8c5720 --- /dev/null +++ b/codeforces/problemsets/theatreSquare/a.cpp @@ -0,0 +1,21 @@ +#include + +using namespace std; + + +int main(){ + ios::sync_with_stdio(0); + cin.tie(0); + + long long n, m, a; + + cin >> n >> m >> a; + + long long result = ceil((double)n / (double)a) * ceil((double)m / (double)a); + + cout << result; + + cout << flush; + + return 0; +} diff --git a/codeforces/problemsets/twins/twins.cpp b/codeforces/problemsets/twins/twins.cpp new file mode 100644 index 0000000..ea25486 --- /dev/null +++ b/codeforces/problemsets/twins/twins.cpp @@ -0,0 +1,39 @@ +#include + +using namespace std; + + +int main(){ + ios::sync_with_stdio(0); + cin.tie(0); + + int t, c, sum=0; + cin >> t; + + vector coins; + + for(int n = 0; n < t; n++){ + cin >> c; + sum += c; + coins.push_back(c); + } + + sort(coins.begin(), coins.end()); + reverse(coins.begin(), coins.end()); + + float half = (float)sum / 2; + int acc = 0, result = 0; + for(int& i : coins){ + acc += i; + result++; + if(acc > half){ + break; + } + } + + cout << result; + + cout << flush; + + return 0; +} \ No newline at end of file diff --git a/codeforces/problemsets/watermelon/watermelon.cpp b/codeforces/problemsets/watermelon/watermelon.cpp new file mode 100644 index 0000000..cbe0dc8 --- /dev/null +++ b/codeforces/problemsets/watermelon/watermelon.cpp @@ -0,0 +1,24 @@ +#include +#include +#include +#include + +using namespace std; + +int main(){ + ios::sync_with_stdio(0); + cin.tie(0); + + int n; + cin >> n; + + if(n > 2 && n % 2 == 0){ + cout << "YES"; + } else{ + cout << "NO"; + } + + cout << flush; + + return 0; +} \ No newline at end of file diff --git a/codeforces/problemsets/wayTooLongWords/wayTooLongWords.cpp b/codeforces/problemsets/wayTooLongWords/wayTooLongWords.cpp new file mode 100644 index 0000000..5411b16 --- /dev/null +++ b/codeforces/problemsets/wayTooLongWords/wayTooLongWords.cpp @@ -0,0 +1,35 @@ +#include +#include +#include +#include + +using namespace std; + +void test_case(int tc){ + string s; + cin >> s; + + if(s.length() > 10){ + cout << s.front() << s.length() - 2 << s.back() << '\n'; + } else{ + cout << s << '\n'; + } +} + + + +int main(){ + ios::sync_with_stdio(0); + cin.tie(0); + + int t; + cin >> t; + + for(int tc = 1; tc <= t; ++tc){ + test_case(tc); + } + + cout << flush; + + return 0; +} \ No newline at end of file diff --git a/codeforces/problemsets/youngPhysicist/a.cpp b/codeforces/problemsets/youngPhysicist/a.cpp new file mode 100644 index 0000000..5b827af --- /dev/null +++ b/codeforces/problemsets/youngPhysicist/a.cpp @@ -0,0 +1,29 @@ +#include + +using namespace std; + + +int main(){ + ios::sync_with_stdio(0); + cin.tie(0); + + int n, a, b, c, x = 0, y = 0, z = 0; + cin >> n; + + for(int i = 0; i < n; ++i){ + cin >> a >> b >> c; + x += a; + y += b; + z += c; + } + + if(x == 0 && y == 0 && z == 0){ + cout << "YES"; + } else{ + cout << "NO"; + } + + cout << flush; + + return 0; +}