Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- const int N = 1e6+7;
- int vis[N];
- int main() {
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- // freopen("/home/hamoudi/Coding/run.in", "r", stdin);
- int tt = 1;
- // cin >> tt;
- while (tt--) {
- int n;
- cin >> n;
- string input_text = "";
- string str;
- for (int i = 0; i < n; ++i) {
- cin >> str;
- if (i > 0) input_text += " ";
- input_text += str;
- }
- int m;
- cin >> m;
- // it will be true because we start with lowercase
- bool lower = true;
- string operation;
- string final_result = "";
- while (m--) {
- cin >> operation;
- if (operation == "CapsLock") {
- lower = !lower;
- // just flip lower to upper and vice versa
- } else if (operation == "Backspace") {
- // first check if input text is empty or not
- if (not final_result.empty())
- final_result.pop_back(); // remove the last if it's not empty
- } else if (operation == "Space") {
- // add space to final string
- final_result += " ";
- } else {
- // in this case we must have input character to add
- // so i have to check Capslock
- if (lower) {
- final_result += tolower(operation[0]);
- } else {
- final_result += toupper(operation[0]);
- }
- }
- }
- if (final_result == input_text)
- cout << "Correct";
- else
- cout << "Incorrect";
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement