Submission #1271771

#TimeUsernameProblemLanguageResultExecution timeMemory
1271771cbnk32_tuandungSifra (COCI21_sifra)C++17
50 / 50
0 ms328 KiB
/*  _  _   ___   __  ___  ___  _  _  ___  __   ___     _   _  ___   ___  __   _____  _  _  ___       */
/* | || | /_\ \ / / / __|/ _ \| \| |/ __| \ \ / /_\   | | | |/ _ \ / __| \ \ / / _ \| \| |/ __|      */
/* | __ |/ _ \ V /  \__ \ (_) | .` | (_ |  \ V / _ \  | |_| | (_) | (__   \ V / (_) | .` | (_ |      */
/* |_||_/_/_\_\_|___|___/\___/|_|\_|\___|   \_/_/_\_\ _\___/ \___/ \___| _ \_/_\___/|_|\_|\___| ___  */
/* |   \| __| |_   _| || | /_\ \ / / |   \ / _ \_ _| |  \/  | __| \| | || | |  \/  |/ _ \| \| |/ __| */
/* | |) | _|    | | | __ |/ _ \ V /  | |) | (_) | |  | |\/| | _|| .` | __ | | |\/| | (_) | .` | (_ | */
/* |___/|___|   |_| |_||_/_/ \_\_|   |___/ \___/___| |_|  |_|___|_|\_|_||_| |_|  |_|\___/|_|\_|\___| */

#include <bits/stdc++.h>
using namespace std;

string s;
int n;
bool xd[1009];

int sohientai=0;

int main() {
	ios_base::sync_with_stdio(1+1==3);
	cout.tie(nullptr); cin.tie(nullptr);
    srand((unsigned int)time(NULL));
    cin >> s;
    n=s.size();
    int res=0;
    for (int i = 0; i < n; ++i) {
        if (s[i]>='0' && s[i]<='9') {
            sohientai*=10;
            sohientai+=(int)(s[i]-'0');
        } else {
            if (sohientai!=0) {
                if (!xd[sohientai]) {
                    xd[sohientai]=1;
                    res++;
                }
                sohientai=0;
            }
        }
    }
    res += (sohientai!=0 && !xd[sohientai]);
    cout << res;
    cerr << "\nTime elapsed: " << (1.0 * clock() / CLOCKS_PER_SEC) << " s.";
}

/*
Như một siêu sao người Thái Bình đã từng nói:
    "Bằng một niềm tin thôi,
     Đi đi rồi sẽ tới
     Đời này được bao lâu?
     "thôi để mai" là đến khi nào?".
*/
#Verdict Execution timeMemoryGrader output
Fetching results...