klokov__vokolk's blog

By klokov__vokolk, history, 3 years ago, In English

Whenever I start solving a problem during practice I always try to avoid not looking at the tags for problem so that I don't think about the problem in that particular way. By looking at the tag I think we miss on looking at bigger picture(SOMETIMES).

And tags on problem are displayed in such a way you can't avoid looking at them while reading and solving the problem and it feels as if someone is constantly saying just look at the tag and think in that way because it will make the process of thinking less painful because now you got a starting point.

So I think it would be amazing if their is toggle button which by default is off and doesn't display any tags but if someone wants can press it and make tags visible.

I know this won't make a big change but it will definitely help some people just like for editorials we have a link and are not visible on the same page.

Full text and comments »

  • Vote: I like it
  • -7
  • Vote: I do not like it

By klokov__vokolk, history, 3 years ago, In English
#include<bits/stdc++.h>
 
using namespace std;
 
 
 
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MX 1e6
#define MOD 1000000007
#define MOD1 998244353
#define INF 1e18
#define nline "\n"
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ff first
#define ss second
#define PI 3.141592653589793238462
#define set_bits __builtin_popcountll
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
// typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update > pbds; // find_by_order, order_of_key
 
#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x <<" "; _print(x); cerr << endl;
#else
#define debug(x)
#endif
 
void _print(ll t) {cerr << t;}
void _print(int t) {cerr << t;}
void _print(string t) {cerr << t;}
void _print(char t) {cerr << t;}
void _print(lld t) {cerr << t;}
void _print(double t) {cerr << t;}
void _print(ull t) {cerr << t;}
 
template <class T, class V> void _print(pair <T, V> p);
template <class T> void _print(vector <T> v);
template <class T> void _print(set <T> v);
template <class T, class V> void _print(map <T, V> v);
template <class T> void _print(multiset <T> v);
template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.ff); cerr << ","; _print(p.ss); cerr << "}";}
template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";}
 
bool comp1(pair<int, int> a, pair<int, int> b){ return a.ff < b.ff;}
bool comp2(pair<int, int> a, pair<int, int> b){ return a.ss < b.ss;}

bool isValidSequence (string str) {
    stack<char> s;

    for (int i = 0; i < str.size(); i++) {
        if (str[i] == '(') {
            s.push('(');
        } else if (str[i] == ')' && s.top() == '(') {
            s.pop();
        } else if (str[i] == ')' && s.top() == ')') {
            s.push(')');
        }
    }

    if (s.size()) {
        return false;
    }

    return true;
}

void solve() {
    string str;
    // this is point where i am facing the problem and not able to figure out what am i doing wrong.
    cin>>str;

    int n = str.length();

    char first = str[0];
    char last = str[n - 1];

    if (first == last) {
        cout<<"NO"<<"\n";
        return;
    }

    vector<string> vec(2);

    for (int i = 0; i < n; i++) {
        if (str[i] == first) {
            vec[0].pb('(');
        } else if (str[i] == last) {
            vec[0].pb(')');
        } else {
            vec[0].pb('(');
        }
    }

    for (int i = 0; i < n; i++) {
        if (str[i] == first) {
            vec[1].pb('(');
        } else if (str[i] == last) {
            vec[1].pb(')');
        } else {
            vec[1].pb(')');
        }
    }

    for (auto var : vec) {
        if (isValidSequence(var)) {
            cout<<"YES"<<"\n";
            return;
        }
    }

    cout<<"NO"<<"\n";
    return;
}

int main() {
 
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("error.txt", "w", stderr);
    freopen("output.txt", "w", stdout);
#endif 

    int t;
    cin>>t;

    while (t--) {
        solve();
    }
    return 0;
}

I don't know what's wrong is going on but for input t = 1 string s = ABBB I am not able to read the string and tried a lot to figure out the error but couldn't solve it please help

Full text and comments »

  • Vote: I like it
  • -8
  • Vote: I do not like it

By klokov__vokolk, history, 3 years ago, In English

When I am practicing problems most of the time it's hard for me to get the idea to solve the problem on the first go. So if I am not able to get the approach I go and watch the editorial but for some contests the contest organizers don't post only the editorials but also some hints to approach the problem and it happens with me that just by reading one hint I start getting the on how to tackle the problem instead of reading the whole editorial. So my point is for every contest the editorials should have some hints too. I know this might be too much to ask for because the problem writers and testers are doing a spectacular and hard work in organizing these contests and helping everyone to work on them. Because a lot of efforts goes in organizing a contest but it would be super amazing to get hints also. Although now most of the contests editorials do have hints but it would be amazing if all contests editorials have these hints. (Pardon me for my bad English)

Full text and comments »

  • Vote: I like it
  • +12
  • Vote: I do not like it

By klokov__vokolk, history, 5 years ago, In English

HURRAY

Wow this was really amazing for me for the past one year i was trying to get into competitive programming but wasn't never giving time to it but during this lock down I actually started doing it. I participated in 2-3 contest in this span of time but in every contest wasn't able to solve even the first question but then i saw div 4 at first I thought that it is some of kind of mistake by it was true and here i took the chance and solve my first question I can't tell you about the feeling Oh god it felt so good i wanna thank Mike Mirzayanov for this contest it really boosted my confidence.

Full text and comments »

  • Vote: I like it
  • +66
  • Vote: I do not like it